home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gpp-1_42.lha / g++-1.42.0 / cplus-lex.c < prev    next >
C/C++ Source or Header  |  1991-10-19  |  104KB  |  4,048 lines

  1. /* Separate lexical analyzer for GNU C++.
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.    Hacked by Michael Tiemann (tiemann@mcc.com)
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. /* This file is the lexical analyzer for GNU C++.  */
  23.  
  24. #include <sys/types.h>
  25. #include <stdio.h>
  26. #include <errno.h>
  27. #include <setjmp.h>
  28. #include <string.h>
  29. #include "config.h"
  30. #include "input.h"
  31. #include "tree.h"
  32. #ifdef VMS
  33. #define _IOFBF 2        /* Missing from GNU's stdio.h */
  34. #endif
  35. #include "cplus-tab.h"
  36. #include "cplus-parse.h"
  37. #include "cplus-tree.h"
  38. #include "flags.h"
  39. #include "obstack.h"
  40. #include "assert.h"
  41.  
  42. /* Define getpagesize () if the system does not.  */
  43. #include "getpagesize.h"
  44.  
  45. extern int errno;        /* needed for VAX.  */
  46. extern jmp_buf toplevel;
  47.  
  48. #ifdef VMS
  49. #define    NULL_FILE    "nla0:"
  50. #else
  51. #define    NULL_FILE    "/dev/null"
  52. #endif
  53.  
  54. #define obstack_chunk_alloc xmalloc
  55. #define obstack_chunk_free free
  56.  
  57. extern int xmalloc ();
  58. extern void free ();
  59.  
  60. extern double atof ();
  61.  
  62. /* If you don't have strrchr, but instead have rindex,
  63.    add your machine to this list, and send mail to
  64.    tiemann@wheaties.ai.mit.edu.  */
  65. #if defined(sequent) || defined(convex)
  66. #define strrchr rindex
  67. #endif
  68. extern char *strrchr ();
  69.  
  70. /* This obstack is needed to hold text.  It is not safe to use
  71.    TOKEN_BUFFER because `check_newline' calls `yylex'.  */
  72. static struct obstack inline_text_obstack;
  73. static char *inline_text_firstobj;
  74.  
  75. /* Holds translations from TREE_CODEs to operator name strings,
  76.    i.e., opname_tab[PLUS_EXPR] == "+".  */
  77. char **opname_tab;
  78. char **assignop_tab;
  79.  
  80. #define YYEMPTY        -2
  81. int    yychar;            /*  the lookahead symbol        */
  82. YYSTYPE    yylval;            /*  the semantic value of the        */
  83.                 /*  lookahead symbol            */
  84.  
  85. #if 0
  86. YYLTYPE yylloc;            /*  location data for the lookahead    */
  87.                 /*  symbol                */
  88. #endif
  89.  
  90. int end_of_file;
  91.  
  92. /* the declaration found for the last IDENTIFIER token read in.
  93.    yylex must look this up to detect typedefs, which get token type TYPENAME,
  94.    so it is left around in case the identifier is not a typedef but is
  95.    used in a context which makes it a reference to a variable.  */
  96. tree lastiddecl;
  97.  
  98. /* C++ extensions */
  99. tree ridpointers[];        /* need this up here */
  100.  
  101. /* We may keep statistics about how long which files took to compile.  */
  102. static int header_time, body_time;
  103. static tree get_time_identifier ();
  104. static tree filename_times;
  105. static tree this_filename_time;
  106.  
  107. /* For implementing #pragma unit.  */
  108. tree current_unit_name;
  109. tree current_unit_language;
  110.  
  111. /* Array for holding counts of the numbers of tokens seen.  */
  112. int *token_count;
  113.  
  114. /* Return something to represent absolute declarators containing a *.
  115.    TARGET is the absolute declarator that the * contains.
  116.    TYPE_QUALS is a list of modifiers such as const or volatile
  117.    to apply to the pointer type, represented as identifiers.
  118.  
  119.    We return an INDIRECT_REF whose "contents" are TARGET
  120.    and whose type is the modifier list.  */
  121.  
  122. tree
  123. make_pointer_declarator (type_quals, target)
  124.      tree type_quals, target;
  125. {
  126.   if (target && TREE_CODE (target) == IDENTIFIER_NODE
  127.       && ANON_AGGRNAME_P (target))
  128.     error ("type name expected before `*'");
  129.   return build1 (INDIRECT_REF, type_quals, target);
  130. }
  131.  
  132. /* Return something to represent absolute declarators containing a &.
  133.    TARGET is the absolute declarator that the & contains.
  134.    TYPE_QUALS is a list of modifiers such as const or volatile
  135.    to apply to the reference type, represented as identifiers.
  136.  
  137.    We return an ADDR_EXPR whose "contents" are TARGET
  138.    and whose type is the modifier list.  */
  139.    
  140. tree
  141. make_reference_declarator (type_quals, target)
  142.      tree type_quals, target;
  143. {
  144.   if (target)
  145.     {
  146.       if (TREE_CODE (target) == ADDR_EXPR)
  147.     {
  148.       error ("cannot declare references to references");
  149.       return target;
  150.     }
  151.       if (TREE_CODE (target) == INDIRECT_REF)
  152.     {
  153.       error ("cannot declare pointers to references");
  154.       return target;
  155.     }
  156.       if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
  157.       error ("type name expected before `&'");
  158.     }
  159.   return build1 (ADDR_EXPR, type_quals, target);
  160. }
  161.  
  162. /* Given a chain of STRING_CST nodes,
  163.    concatenate them into one STRING_CST
  164.    and give it a suitable array-of-chars data type.  */
  165.  
  166. tree
  167. combine_strings (strings)
  168.      tree strings;
  169. {
  170.   register tree value, t;
  171.   register int length = 1;
  172.   int wide_length = 0;
  173.   int wide_flag = 0;
  174.  
  175.   if (TREE_CHAIN (strings))
  176.     {
  177.       /* More than one in the chain, so concatenate.  */
  178.       register char *p, *q;
  179.  
  180.       /* Don't include the \0 at the end of each substring,
  181.      except for the last one.
  182.      Count wide strings and ordinary strings separately.  */
  183.       for (t = strings; t; t = TREE_CHAIN (t))
  184.     {
  185.       if (TREE_TYPE (t) == int_array_type_node)
  186.         {
  187.           wide_length += (TREE_STRING_LENGTH (t) - 1);
  188.           wide_flag = 1;
  189.         }
  190.       else
  191.         length += (TREE_STRING_LENGTH (t) - 1);
  192.     }
  193.  
  194.       /* If anything is wide, the non-wides will be converted,
  195.      which makes them take more space.  */
  196.       if (wide_flag)
  197.     length = length * UNITS_PER_WORD + wide_length;
  198.  
  199.       p = (char *) savealloc (length);
  200.  
  201.       /* Copy the individual strings into the new combined string.
  202.      If the combined string is wide, convert the chars to ints
  203.      for any individual strings that are not wide.  */
  204.  
  205.       q = p;
  206.       for (t = strings; t; t = TREE_CHAIN (t))
  207.     {
  208.       int len = TREE_STRING_LENGTH (t) - 1;
  209.       if ((TREE_TYPE (t) == int_array_type_node) == wide_flag)
  210.         {
  211.           bcopy (TREE_STRING_POINTER (t), q, len);
  212.           q += len;
  213.         }
  214.       else
  215.         {
  216.           int i;
  217.           for (i = 0; i < len; i++)
  218.         ((int *) q)[i] = TREE_STRING_POINTER (t)[i];
  219.           q += len * UNITS_PER_WORD;
  220.         }
  221.     }
  222.       *q = 0;
  223.  
  224.       value = make_node (STRING_CST);
  225.       TREE_STRING_POINTER (value) = p;
  226.       TREE_STRING_LENGTH (value) = length;
  227.       TREE_LITERAL (value) = 1;
  228.     }
  229.   else
  230.     {
  231.       value = strings;
  232.       length = TREE_STRING_LENGTH (value);
  233.       if (TREE_TYPE (value) == int_array_type_node)
  234.     wide_flag = 1;
  235.     }
  236.  
  237.   /* Create the array type for the string constant.
  238.      -Wwrite-strings says make the string constant an array of const char
  239.      so that copying it to a non-const pointer will get a warning.  */
  240.   if (warn_write_strings)
  241.     {
  242.       tree elements
  243.     = build_type_variant (wide_flag ? integer_type_node : char_type_node,
  244.                   1, 0);
  245.       TREE_TYPE (value)
  246.     = build_array_type (elements,
  247.                 build_index_type (build_int_2 (length - 1, 0)));
  248.     }
  249.   else
  250.     TREE_TYPE (value)
  251.       = build_array_type (wide_flag ? integer_type_node : char_type_node,
  252.               build_index_type (build_int_2 (length - 1, 0)));
  253.   TREE_LITERAL (value) = 1;
  254.   TREE_STATIC (value) = 1;
  255.   return value;
  256. }
  257.  
  258. /* Build names and nodes for overloaded operators.  */
  259.  
  260. /* Memoized table for operator names.  */
  261. tree *node_table;
  262.  
  263. tree
  264. build_opid (code1, code2)
  265.      enum tree_code code1, code2;
  266. {
  267.   register tree t = make_node (OP_IDENTIFIER);
  268.   register tree tmp;
  269.   extern struct obstack *expression_obstack, permanent_obstack;
  270.   struct obstack *ambient_obstack = expression_obstack;
  271.   expression_obstack = &permanent_obstack;
  272.   if (code1 != 0)
  273.     {
  274.       if ((tmp = node_table[(int)code1]) == 0)
  275.     node_table[(int)code1] = tmp = make_node (code1);
  276.       TREE_PURPOSE (t) = tmp;
  277.     }
  278.   if ((tmp = node_table[(int)code2]) == 0)
  279.     node_table[(int)code2] = tmp = make_node (code2);
  280.   TREE_VALUE (t) = tmp;
  281.   expression_obstack = ambient_obstack;
  282.   return t;
  283. }
  284.  
  285. #ifdef __GNUC__
  286. #define DEFTREECODE(SYM, NAME, TYPE, LEN) sizeof (NAME),
  287. #else
  288. #define DEFTREECODE(SYM, NAME, TYPE, LEN) -1,
  289. #endif
  290. static short opname_end[] = {
  291. #include "tree.def"
  292. 7,                /* sizeof ("@@dummy"), */
  293. #include "cplus-tree.def"
  294. };
  295. #undef DEFTREECODE
  296.  
  297. /* Given a TOKEN and its estimated tree code CODE, produce a name which
  298.    can be recognized by lookup_name.  Based on the number of PARMS,
  299.    build an appropriate operator fnname.  This function is needed because
  300.    until we know how many parameters we have, we cannot reliably tell
  301.    what function indeed we are trying to declare.
  302.  
  303.    NPARMS is the number of additional parameters that this operator
  304.    will ultimately have.  If NPARMS == -1, then we are just building
  305.    a name, and should not complain.
  306.  
  307.    This would be a good candidate for memoizing.  */
  308. tree
  309. build_operator_fnname (declp, parms, nparms)
  310.      tree *declp;
  311.      tree parms;
  312.      int nparms;
  313. {
  314.   tree decl = *declp;
  315.   char **opname_table, *opname;
  316.   int assignop_p = 0;
  317.   tree rval;
  318.   enum tree_code code;
  319.   char buf[1024];
  320.   int saw_class = nparms;
  321.   int erred = 0;
  322.  
  323.   while (parms)
  324.     {
  325.       tree type;
  326.       if (parms == void_list_node)
  327.     break;
  328.  
  329.       if (! saw_class)
  330.     {
  331.       type = TREE_VALUE (parms);
  332.       if (TREE_CODE (type) == REFERENCE_TYPE)
  333.         type = TREE_TYPE (type);
  334.       if (TREE_CODE (type) == POINTER_TYPE)
  335.         type = TREE_TYPE (type);
  336.       if (IS_AGGR_TYPE (type))
  337.         saw_class = 1;
  338.     }
  339.       nparms++;
  340.       parms = TREE_CHAIN (parms);
  341.     }
  342.  
  343.   if (TREE_CODE (decl) == TYPE_EXPR)
  344.     {
  345.       /* @@ may need to perform type instantiation here.  */
  346.       if (nparms > 1)
  347.     error ("wrong number of arguments to type conversion operator");
  348.  
  349.       /* The grammar will swallow an "()" if one was given.
  350.      We attempt to correct for this lossage here.  */
  351.       if (TREE_OPERAND (decl, 0)
  352.       && TREE_CODE (TREE_OPERAND (decl, 0)) == CALL_EXPR)
  353.     {
  354.       rval = build_typename_overload (groktypename (build_tree_list (TREE_TYPE (decl), NULL_TREE)));
  355.       yychar = LEFT_RIGHT;
  356.     }
  357.       else
  358.     {
  359.       rval = build_typename_overload (groktypename (build_tree_list (TREE_TYPE (decl), TREE_OPERAND (decl, 0))));
  360.     }
  361.       return rval;
  362.     }
  363.  
  364.   if (TREE_PURPOSE (decl))
  365.     if (TREE_CODE (TREE_PURPOSE (decl)) == MODIFY_EXPR)
  366.       {
  367.     opname_table = assignop_tab;
  368.     assignop_p = 1;
  369.       }
  370.     else
  371.       abort ();
  372.   else
  373.     opname_table = opname_tab;
  374.  
  375.   code = TREE_CODE (TREE_VALUE (decl));
  376.   opname = opname_table[(int) code];
  377.  
  378.   if (assignop_p)
  379.     {
  380.       if (nparms == 1 || nparms > 2)
  381.     error ("wrong number of parameters op `operator %s'", opname);
  382.     }
  383.   else switch (code)
  384.     {
  385.     case ERROR_MARK:
  386.       rval = get_identifier ("<invalid operator>");
  387.       TREE_OVERLOADED (rval) = 1;
  388.       return rval;
  389.  
  390.       /* AC/DC */
  391.     case PLUS_EXPR:
  392.       if (nparms == 1)
  393.     code = CONVERT_EXPR;
  394.       else if (nparms != 2)
  395.     erred = 1;
  396.       break;
  397.  
  398.     case ADDR_EXPR:
  399.     case BIT_AND_EXPR:
  400.       if (nparms == 1)
  401.     code = ADDR_EXPR;
  402.       else if (nparms == 2)
  403.     code = BIT_AND_EXPR;
  404.       else
  405.     {
  406.       code = BIT_AND_EXPR;
  407.       erred = 1;
  408.     }
  409.       break;
  410.  
  411.     case MULT_EXPR:
  412.     case INDIRECT_REF:
  413.       if (nparms == 1)
  414.     code = INDIRECT_REF;
  415.       else if (nparms == 2)
  416.     code = MULT_EXPR;
  417.       else
  418.     {
  419.       code = MULT_EXPR;
  420.       erred = 1;
  421.     }
  422.       break;
  423.  
  424.     case MINUS_EXPR:
  425.     case NEGATE_EXPR:
  426.       if (nparms == 1)
  427.     code = NEGATE_EXPR;
  428.       else if (nparms == 2)
  429.     code = MINUS_EXPR;
  430.       else
  431.     {
  432.       code = MINUS_EXPR;
  433.       erred = 1;
  434.     }
  435.       break;
  436.  
  437.     case POINTSAT:
  438.       if (nparms == 1 || nparms < 0)
  439.     code = COMPONENT_REF;
  440.       else
  441.     {
  442.       erred = -1;
  443.       error ("wrong number of parameters to `operator ->()'");
  444.     }
  445.       break;
  446.  
  447.     case METHOD_CALL_EXPR:
  448.       switch (nparms)
  449.     {
  450.     case 0:
  451.     case 1:
  452.       erred = -1;
  453.       error ("too few arguments to `operator ->()(...)'");
  454.       break;
  455.       /* 4 happens when we pass in the canonical number
  456.          of arguments.  */
  457.     case 4:
  458.       nparms = 3;
  459.     case -1:
  460.     case 2:
  461.     case 3:
  462.       break;
  463.     default:
  464.       erred = -1;
  465.       error ("too many arguments to `operator ->()(...)'");
  466.       break;
  467.     }
  468.       break;
  469.  
  470.       /* The two following entrys are for two different ways of
  471.      encoding `operator ='.  */
  472.     case NOP_EXPR:
  473.       if (nparms != 2 && nparms >= 0)
  474.     erred = 1;
  475.       break;
  476.  
  477.     case MODIFY_EXPR:
  478.       if (nparms != 2 && nparms >= 0)
  479.     erred = 1;
  480.       break;
  481.  
  482.     case NEW_EXPR:
  483.       if (saw_class == 0)
  484.     {
  485.       if (nparms > 1)
  486.         return get_identifier (OPERATOR_NEW_FORMAT);
  487.       return get_identifier ("__builtin_new");
  488.     }
  489.       break;
  490.  
  491.     case DELETE_EXPR:
  492.       if (saw_class == 0)
  493.     {
  494.       if (nparms > 1)
  495.         error ("too many parameters to `operator ::delete'");
  496.       return get_identifier ("__builtin_delete");
  497.     }
  498.       if (nparms > 2)
  499.     erred = 1;
  500.       break;
  501.  
  502.       /* Whatever it was, we know its arity.  Just check that it
  503.          has the right number of parameters defined.  */
  504.     default:
  505.       /* These are the only operators which do not need
  506.      to have a class-type associated with them.  */
  507.  
  508.       if (code == PREDECREMENT_EXPR
  509.       || code == POSTINCREMENT_EXPR
  510.       || code == COMPONENT_REF)
  511.     {
  512.       if (nparms > 1)
  513.         erred = 1;
  514.     }
  515.       else if (nparms < 0
  516.            || code == CALL_EXPR
  517.            || code == METHOD_CALL_EXPR)
  518.     ;
  519.       else if (nparms != tree_code_length [(int) code])
  520.     erred = 1;
  521.       break;
  522.     }
  523.  
  524.   if (erred > 0)
  525.     error ("wrong number of parameters to `operator %s'", opname);
  526.   else if (erred == 0 && code != TREE_CODE (TREE_VALUE (decl)))
  527.     {
  528.       enum tree_code assign_code = ERROR_MARK;
  529.       if (TREE_PURPOSE (decl))
  530.     assign_code = TREE_CODE (TREE_PURPOSE (decl));
  531.       decl = build_opid (assign_code, code);
  532.       *declp = decl;
  533.     }
  534.  
  535.   if (! saw_class)
  536.     error ("`operator %s' must have at least one class type", opname);
  537.  
  538.   if (assignop_p)
  539.     {
  540.       sprintf (buf, OPERATOR_ASSIGN_FORMAT, tree_code_name [(int) code]);
  541.       buf[opname_end[(int) code] + sizeof (OPERATOR_ASSIGN_FORMAT) - 3] = '\0';
  542.     }
  543.   else
  544.     {
  545.       sprintf (buf, OPERATOR_FORMAT, tree_code_name [(int) code]);
  546.       buf[opname_end[(int) code] + sizeof (OPERATOR_FORMAT) - 3] = '\0';
  547.     }      
  548.   rval = get_identifier (buf);
  549.   TREE_OVERLOADED (rval) = 1;
  550.   return rval;
  551. }
  552.  
  553. char *
  554. operator_name_string (name)
  555.      tree name;
  556. {
  557.   char *opname = IDENTIFIER_POINTER (name)
  558.     + sizeof (OPERATOR_FORMAT) - sizeof ("%s");
  559.   int i, assign;
  560.  
  561.   /* Works for builtin and user defined types.  */
  562.   if (IDENTIFIER_GLOBAL_VALUE (name)
  563.       && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL)
  564.     return IDENTIFIER_POINTER (name);
  565.  
  566.   if (! strncmp (opname, "assign", 6))
  567.     {
  568.       opname += 7;
  569.       assign = 1;
  570.     }
  571.   else
  572.     assign = 0;
  573.  
  574.   for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
  575.     {
  576.       if (! strncmp (opname, tree_code_name[i], opname_end[i]))
  577.     break;
  578.     }
  579.  
  580.   if (i == LAST_CPLUS_TREE_CODE)
  581.     return "<invalid operator>";
  582.  
  583.   if (assign)
  584.     return assignop_tab[i];
  585.   else
  586.     return opname_tab[i];
  587. }
  588.  
  589. int lineno;            /* current line number in file being read */
  590.  
  591. FILE *finput;            /* input file.
  592.                    Normally a pipe from the preprocessor.  */
  593. static FILE *finput1;        /* Real input files: 1 is main input file */
  594. static FILE *finput2;        /* 2 is input file for inline functions */
  595.  
  596. int interface_only;        /* whether or not current file is only for
  597.                    interface definitions.  */
  598. int interface_unknown;        /* whether or not we know this class
  599.                    to behave according to #pragma interface.  */
  600.  
  601. /* lexical analyzer */
  602.  
  603. static int maxtoken;        /* Current nominal length of token buffer.  */
  604. char *token_buffer;        /* Pointer to token buffer.
  605.                    Actual allocated length is maxtoken + 2.  */
  606. static int max_wide;        /* Current nominal length of wide_buffer.  */
  607. static int *wide_buffer;    /* Pointer to wide-string buffer.
  608.                    Actual allocated length is max_wide + 1.  */
  609.  
  610. #define NORID RID_UNUSED
  611.  
  612. /* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$ gplus.gperf  */
  613. struct resword { char *name; short token; enum rid rid;};
  614.  
  615. #define MIN_WORD_LENGTH 2
  616. #define MAX_WORD_LENGTH 13
  617. #define MIN_HASH_VALUE 4
  618. #define MAX_HASH_VALUE 147
  619. /*
  620.    71 keywords
  621.   144 is the maximum key range
  622. */
  623.  
  624. #ifdef __GNUC__
  625. inline
  626. #endif
  627. static int
  628. hash (str, len)
  629.      register char *str;
  630.      register int unsigned len;
  631. {
  632.   static unsigned char hash_table[] =
  633.     {
  634.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  635.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  636.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  637.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  638.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  639.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  640.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  641.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  642.      147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
  643.      147, 147, 147, 147, 147,   0, 147,  19,   6,  27,
  644.       37,   0,  12,   1,  15,  63, 147,   4,   0,  56,
  645.       20,  15,  42, 147,  31,   5,  26,  39,  32,  10,
  646.      147,  40, 147, 147, 147, 147, 147, 147,
  647.     };
  648.   register int hval = len ;
  649.  
  650.   switch (hval)
  651.     {
  652.       default:
  653.       case 4:
  654.         hval += hash_table[str[3]];
  655.       case 3:
  656.       case 2:
  657.       case 1:
  658.         hval += hash_table[str[0]];
  659.     }
  660.   return hval + hash_table[str[len - 1]] ;
  661. }
  662.  
  663. #ifdef __GNUC__
  664. inline
  665. #endif
  666. struct resword *
  667. is_reserved_word (str, len)
  668.      register char *str;
  669.      register unsigned int len;
  670. {
  671.  
  672.   static struct resword  wordlist[] =
  673.     {
  674.       {"",}, {"",}, {"",}, {"",}, 
  675.       {"else",  ELSE, NORID,},
  676.       {"",}, 
  677.       {"long",  TYPESPEC, RID_LONG,},
  678.       {"",}, {"",}, {"",}, {"",}, 
  679.       {"__alignof__",  ALIGNOF, NORID},
  680.       {"__asm__",  ASM, NORID},
  681.       {"",}, {"",}, 
  682.       {"while",  WHILE, NORID,},
  683.       {"",}, {"",}, {"",}, {"",}, {"",}, 
  684.       {"__alignof",  ALIGNOF, NORID},
  685.       {"all",  ALL, NORID            /* Extension */,},
  686.       {"sizeof",  SIZEOF, NORID,},
  687.       {"__const__",  TYPE_QUAL, RID_CONST},
  688.       {"__volatile",  TYPE_QUAL, RID_VOLATILE},
  689.       {"extern",  SCSPEC, RID_EXTERN,},
  690.       {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
  691.       {"__inline",  SCSPEC, RID_INLINE},
  692.       {"exception",  AGGR, RID_EXCEPTION    /* Extension */,},
  693.       {"__inline__",  SCSPEC, RID_INLINE},
  694.       {"case",  CASE, NORID,},
  695.       {"except",  EXCEPT, NORID        /* Extension */,},
  696.       {"new",  NEW, NORID,},
  697.       {"break",  BREAK, NORID,},
  698.       {"goto",  GOTO, NORID,},
  699.       {"",}, 
  700.       {"__attribute",  ATTRIBUTE, NORID},
  701.       {"",}, 
  702.       {"__attribute__",  ATTRIBUTE, NORID},
  703.       {"this",  THIS, NORID,},
  704.       {"raise",  RAISE, NORID        /* Extension */,},
  705.       {"class",  AGGR, RID_CLASS,},
  706.       {"delete",  DELETE, NORID,},
  707.       {"typeof",  TYPEOF, NORID,},
  708.       {"typedef",  SCSPEC, RID_TYPEDEF,},
  709.       {"for",  FOR, NORID,},
  710.       {"raises",  RAISES, NORID        /* Extension */,},
  711.       {"__const",  TYPE_QUAL, RID_CONST},
  712.       {"double",  TYPESPEC, RID_DOUBLE,},
  713.       {"__typeof__",  TYPEOF, NORID},
  714.       {"",}, 
  715.       {"switch",  SWITCH, NORID,},
  716.       {"auto",  SCSPEC, RID_AUTO,},
  717.       {"do",  DO, NORID,},
  718.       {"friend",  SCSPEC, RID_FRIEND,},
  719.       {"",}, 
  720.       {"reraise",  RERAISE, NORID        /* Extension */,},
  721.       {"",}, 
  722.       {"volatile",  TYPE_QUAL, RID_VOLATILE,},
  723.       {"__typeof",  TYPEOF, NORID},
  724.       {"continue",  CONTINUE, NORID,},
  725.       {"float",  TYPESPEC, RID_FLOAT,},
  726.       {"const",  TYPE_QUAL, RID_CONST,},
  727.       {"static",  SCSPEC, RID_STATIC,},
  728.       {"virtual",  SCSPEC, RID_VIRTUAL,},
  729.       {"__asm",  ASM, NORID},
  730.       {"short",  TYPESPEC, RID_SHORT,},
  731.       {"signed",  TYPESPEC, RID_SIGNED,},
  732.       {"try",  TRY, NORID            /* Extension */,},
  733.       {"",}, {"",}, {"",}, 
  734.       {"__signed__",  TYPESPEC, RID_SIGNED},
  735.       {"catch",  CATCH, NORID,},
  736.       {"public",  PUBLIC, NORID,},
  737.       {"struct",  AGGR, RID_RECORD,},
  738.       {"if",  IF, NORID,},
  739.       {"asm",  ASM, NORID,},
  740.       {"union",  AGGR, RID_UNION,},
  741.       {"",}, 
  742.       {"private",  PRIVATE, NORID,},
  743.       {"",}, {"",}, {"",}, 
  744.       {"operator",  OPERATOR, NORID,},
  745.       {"",}, {"",}, {"",}, 
  746.       {"default",  DEFAULT, NORID,},
  747.       {"dynamic",  DYNAMIC, NORID,},
  748.       {"overload",  OVERLOAD, NORID,},
  749.       {"int",  TYPESPEC, RID_INT,},
  750.       {"char",  TYPESPEC, RID_CHAR,},
  751.       {"",}, {"",}, 
  752.       {"return",  RETURN, NORID,},
  753.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  754.       {"",}, {"",}, 
  755.       {"__signed",  TYPESPEC, RID_SIGNED},
  756.       {"",}, 
  757.       {"void",  TYPESPEC, RID_VOID,},
  758.       {"",}, {"",}, {"",}, 
  759.       {"protected",  PROTECTED, NORID,},
  760.       {"",}, 
  761.       {"enum",  ENUM, NORID,},
  762.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  763.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  764.       {"inline",  SCSPEC, RID_INLINE,},
  765.       {"register",  SCSPEC, RID_REGISTER,},
  766.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  767.       {"",}, {"",}, {"",}, {"",}, 
  768.       {"unsigned",  TYPESPEC, RID_UNSIGNED,},
  769.     };
  770.  
  771.   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  772.     {
  773.       register int key = hash (str, len);
  774.  
  775.       if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
  776.         {
  777.           register char *s = wordlist[key].name;
  778.  
  779.           if (*s == *str && !strcmp (str + 1, s + 1))
  780.             return &wordlist[key];
  781.         }
  782.     }
  783.   return 0;
  784. }
  785.  
  786. /* The elements of `ridpointers' are identifier nodes
  787.    for the reserved type names and storage classes.
  788.    It is indexed by a RID_... value.  */
  789.  
  790. tree ridpointers[(int) RID_MAX];
  791.  
  792. int check_newline ();
  793.  
  794. static int skip_white_space ();
  795.  
  796. static tree
  797. get_time_identifier (name)
  798.      char *name;
  799. {
  800.   tree time_identifier;
  801.   int len = strlen (name);
  802.   char *buf = (char *)alloca (len + 6);
  803.   strcpy (buf, "file ");
  804.   bcopy (name, buf+5, len);
  805.   buf[len+5] = '\0';
  806.   time_identifier = get_identifier (buf);
  807.   if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE)
  808.     {
  809.       int temp = allocation_temporary_p ();
  810.       if (temp)
  811.     end_temporary_allocation ();
  812.       IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
  813.       IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
  814.       IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times;
  815.       filename_times = time_identifier;
  816.       if (temp)
  817.     resume_temporary_allocation ();
  818.     }
  819.   return time_identifier;
  820. }
  821.  
  822. #ifdef __GNUC__
  823. __inline
  824. #endif
  825. static int
  826. my_gettime ()
  827. {
  828.   int old_quiet_flag = quiet_flag;
  829.   int this_time;
  830.   quiet_flag = 0;
  831.   this_time = gettime ();
  832.   quiet_flag = old_quiet_flag;
  833.   return this_time;
  834. }
  835.  
  836. /* Table indexed by tree code giving a string containing a character
  837.    classifying the tree code.  Possibilities are
  838.    t, d, s, c, r and e.  See cplus-tree.def for details.  */
  839.  
  840. #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
  841.  
  842. char *cplus_tree_code_type[] = {
  843.   "x",
  844. #include "cplus-tree.def"
  845. };
  846. #undef DEFTREECODE
  847.  
  848. /* Table indexed by tree code giving number of expression
  849.    operands beyond the fixed part of the node structure.
  850.    Not used for types or decls.  */
  851.  
  852. #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
  853.  
  854. int cplus_tree_code_length[] = {
  855.   0,
  856. #include "cplus-tree.def"
  857. };
  858. #undef DEFTREECODE
  859.  
  860. /* Names of tree components.
  861.    Used for printing out the tree and error messages.  */
  862. #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
  863.  
  864. char *cplus_tree_code_name[] = {
  865.   "@@dummy",
  866. #include "cplus-tree.def"
  867. };
  868. #undef DEFTREECODE
  869.  
  870. void
  871. init_filename_times ()
  872. {
  873.   this_filename_time = get_time_identifier ("<top level>");
  874.   if (flag_detailed_statistics)
  875.     {
  876.       header_time = 0;
  877.       body_time = my_gettime ();
  878.       TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time;
  879.     }
  880. }
  881.  
  882. /* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
  883.    Stuck this hack in to get the files open correctly; this is called
  884.    in place of init_lex if we are an unexec'd binary.    */
  885. void
  886. reinit_lex_for_unexec ()
  887. {
  888.   finput1 = finput;
  889.   finput2 = fopen (NULL_FILE, "r");
  890.   init_filename_times ();
  891. }
  892.  
  893. void
  894. init_lex ()
  895. {
  896.   extern int *init_parse ();
  897.   extern char *(*decl_printable_name) ();
  898.   extern char *lang_printable_name ();
  899.   extern struct rtx_def *(*lang_expand_expr) ();
  900.   extern struct rtx_def *cplus_expand_expr ();
  901.  
  902.   int i;
  903.  
  904.   /* Make identifier nodes long enough for the language-specific slots.  */
  905.   set_identifier_size (sizeof (struct lang_identifier));
  906.   decl_printable_name = lang_printable_name;
  907.   lang_expand_expr = cplus_expand_expr;
  908.  
  909.   tree_code_type
  910.     = (char **) realloc (tree_code_type,
  911.              sizeof (char *) * LAST_CPLUS_TREE_CODE);
  912.   tree_code_length
  913.     = (int *) realloc (tree_code_length,
  914.                sizeof (int) * LAST_CPLUS_TREE_CODE);
  915.   tree_code_name
  916.     = (char **) realloc (tree_code_name,
  917.              sizeof (char *) * LAST_CPLUS_TREE_CODE);
  918.   bcopy (cplus_tree_code_type,
  919.      tree_code_type + LAST_AND_UNUSED_TREE_CODE,
  920.      (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
  921.   bcopy (cplus_tree_code_length,
  922.      tree_code_length + LAST_AND_UNUSED_TREE_CODE,
  923.      (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
  924.   bcopy (cplus_tree_code_name,
  925.      tree_code_name + LAST_AND_UNUSED_TREE_CODE,
  926.      (LAST_CPLUS_TREE_CODE - LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
  927.  
  928.   node_table = (tree *)oballoc (LAST_CPLUS_TREE_CODE * sizeof (tree));
  929.   opname_tab = (char **)oballoc (LAST_CPLUS_TREE_CODE * sizeof (char *));
  930.   assignop_tab = (char **)oballoc (LAST_CPLUS_TREE_CODE * sizeof (char *));
  931.  
  932.   for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
  933.     /* Our only interest is _ref and _expr.  */
  934.     if (tree_code_type[i][0] == 'r' || tree_code_type[i][0] == 'e')
  935.       {
  936.     char *end = (char *)strrchr (tree_code_name[i], '_');
  937.     if (end)
  938.       opname_end[i] = end - tree_code_name[i];
  939. #ifndef __GNUC__
  940.     else
  941.       opname_end[i] = strlen (tree_code_name[i]);
  942. #endif
  943.       }
  944. #ifndef __GNUC__
  945.     else
  946.       opname_end[i] = strlen (tree_code_name[i]);
  947. #endif
  948.  
  949.   init_method ();
  950.   obstack_init (&inline_text_obstack);
  951.   inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
  952.  
  953.   /* Start it at 0, because check_newline is called at the very beginning
  954.      and will increment it to 1.  */
  955.   lineno = 0;
  956.   finput1 = finput;
  957.   finput2 = fopen (NULL_FILE, "r");
  958.   current_function_decl = NULL;
  959.  
  960.   maxtoken = 40;
  961.   token_buffer = (char *) xmalloc (maxtoken + 2);
  962.   max_wide = 40;
  963.   wide_buffer = (int *) xmalloc (max_wide + 1);
  964.  
  965.   ridpointers[(int) RID_INT] = get_identifier ("int");
  966.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT],
  967.               build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]));
  968.   ridpointers[(int) RID_CHAR] = get_identifier ("char");
  969.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR],
  970.               build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]));
  971.   ridpointers[(int) RID_VOID] = get_identifier ("void");
  972.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID],
  973.               build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]));
  974.   ridpointers[(int) RID_FLOAT] = get_identifier ("float");
  975.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT],
  976.               build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT]));
  977.   ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
  978.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE],
  979.               build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE]));
  980.   ridpointers[(int) RID_SHORT] = get_identifier ("short");
  981.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT],
  982.               build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT]));
  983.   ridpointers[(int) RID_LONG] = get_identifier ("long");
  984.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG],
  985.               build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]));
  986.   ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
  987.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED],
  988.               build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]));
  989.   ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
  990.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED],
  991.               build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED]));
  992.   ridpointers[(int) RID_INLINE] = get_identifier ("inline");
  993.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE],
  994.               build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE]));
  995.   ridpointers[(int) RID_CONST] = get_identifier ("const");
  996.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST],
  997.               build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST]));
  998.   ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
  999.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE],
  1000.               build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE]));
  1001.   ridpointers[(int) RID_AUTO] = get_identifier ("auto");
  1002.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO],
  1003.               build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO]));
  1004.   ridpointers[(int) RID_STATIC] = get_identifier ("static");
  1005.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC],
  1006.               build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]));
  1007.   ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
  1008.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN],
  1009.               build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]));
  1010.   ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
  1011.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF],
  1012.               build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF]));
  1013.   ridpointers[(int) RID_REGISTER] = get_identifier ("register");
  1014.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER],
  1015.               build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER]));
  1016.  
  1017.   /* C++ extensions. These are probably not correctly named. */
  1018.   class_type_node = build_int_2 (class_type, 0);
  1019.   TREE_TYPE (class_type_node) = class_type_node;
  1020.   ridpointers[(int) RID_CLASS] = class_type_node;
  1021.  
  1022.   record_type_node = build_int_2 (record_type, 0);
  1023.   TREE_TYPE (record_type_node) = record_type_node;
  1024.   ridpointers[(int) RID_RECORD] = record_type_node;
  1025.  
  1026.   union_type_node = build_int_2 (union_type, 0);
  1027.   TREE_TYPE (union_type_node) = union_type_node;
  1028.   ridpointers[(int) RID_UNION] = union_type_node;
  1029.  
  1030.   enum_type_node = build_int_2 (enum_type, 0);
  1031.   TREE_TYPE (enum_type_node) = enum_type_node;
  1032.   ridpointers[(int) RID_ENUM] = enum_type_node;
  1033.  
  1034.   ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
  1035.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL],
  1036.               build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL]));
  1037.   ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
  1038.   SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND],
  1039.               build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND]));
  1040.  
  1041.   /* Exception handling extensions.  */
  1042.   exception_type_node = build_int_2 (exception_type, 0);
  1043.   TREE_TYPE (exception_type_node) = exception_type_node;
  1044.   ridpointers[(int) RID_EXCEPTION] = exception_type_node;
  1045.  
  1046.   opname_tab[(int) COMPONENT_REF] = "->";
  1047.   opname_tab[(int) METHOD_CALL_EXPR] = "->()";
  1048.   opname_tab[(int) INDIRECT_REF] = "(unary *)";
  1049.   opname_tab[(int) ARRAY_REF] = "[]";
  1050.   opname_tab[(int) MODIFY_EXPR] = "=";
  1051.   opname_tab[(int) NEW_EXPR] = "new";
  1052.   opname_tab[(int) DELETE_EXPR] = "delete";
  1053.   opname_tab[(int) COND_EXPR] = "... ? ... : ...";
  1054.   opname_tab[(int) CALL_EXPR] = "()";
  1055.   opname_tab[(int) PLUS_EXPR] = "+";
  1056.   opname_tab[(int) MINUS_EXPR] = "-";
  1057.   opname_tab[(int) MULT_EXPR] = "*";
  1058.   opname_tab[(int) TRUNC_DIV_EXPR] = "/";
  1059.   opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
  1060.   opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
  1061.   opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
  1062.   opname_tab[(int) TRUNC_MOD_EXPR] = "%";
  1063.   opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
  1064.   opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
  1065.   opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
  1066.   opname_tab[(int) NEGATE_EXPR] = "-";
  1067.   opname_tab[(int) MIN_EXPR] = "<?";
  1068.   opname_tab[(int) MAX_EXPR] = ">?";
  1069.   opname_tab[(int) ABS_EXPR] = "abs";
  1070.   opname_tab[(int) FFS_EXPR] = "ffs";
  1071.   opname_tab[(int) LSHIFT_EXPR] = "<<";
  1072.   opname_tab[(int) RSHIFT_EXPR] = ">>";
  1073.   opname_tab[(int) BIT_IOR_EXPR] = "|";
  1074.   opname_tab[(int) BIT_XOR_EXPR] = "^";
  1075.   opname_tab[(int) BIT_AND_EXPR] = "&";
  1076.   opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
  1077.   opname_tab[(int) BIT_NOT_EXPR] = "~";
  1078.   opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
  1079.   opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
  1080.   opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
  1081.   opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
  1082.   opname_tab[(int) TRUTH_NOT_EXPR] = "!";
  1083.   opname_tab[(int) LT_EXPR] = "<";
  1084.   opname_tab[(int) LE_EXPR] = "<=";
  1085.   opname_tab[(int) GT_EXPR] = ">";
  1086.   opname_tab[(int) GE_EXPR] = ">=";
  1087.   opname_tab[(int) EQ_EXPR] = "==";
  1088.   opname_tab[(int) NE_EXPR] = "!=";
  1089.   opname_tab[(int) IN_EXPR] = "in";
  1090.   opname_tab[(int) SET_LE_EXPR] = "subset";
  1091.   opname_tab[(int) CARD_EXPR] = "#";
  1092.   opname_tab[(int) RANGE_EXPR] = "..";
  1093.   opname_tab[(int) CONVERT_EXPR] = "(unary +)";
  1094.   opname_tab[(int) ADDR_EXPR] = "(unary &)";
  1095.   opname_tab[(int) PREDECREMENT_EXPR] = "--";
  1096.   opname_tab[(int) PREINCREMENT_EXPR] = "++";
  1097.   opname_tab[(int) POSTDECREMENT_EXPR] = "--";
  1098.   opname_tab[(int) POSTINCREMENT_EXPR] = "++";
  1099.   opname_tab[(int) COMPOUND_EXPR] = ",";
  1100.   assignop_tab[(int) NOP_EXPR] = "=";
  1101.   assignop_tab[(int) PLUS_EXPR] =  "+=";
  1102.   assignop_tab[(int) MINUS_EXPR] = "-=";
  1103.   assignop_tab[(int) MULT_EXPR] = "*=";
  1104.   assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
  1105.   assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
  1106.   assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
  1107.   assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
  1108.   assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
  1109.   assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
  1110.   assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
  1111.   assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
  1112.   assignop_tab[(int) MIN_EXPR] = "<?=";
  1113.   assignop_tab[(int) MAX_EXPR] = ">?=";
  1114.   assignop_tab[(int) LSHIFT_EXPR] = "<<=";
  1115.   assignop_tab[(int) RSHIFT_EXPR] = ">>=";
  1116.   assignop_tab[(int) BIT_IOR_EXPR] = "|=";
  1117.   assignop_tab[(int) BIT_XOR_EXPR] = "^=";
  1118.   assignop_tab[(int) BIT_AND_EXPR] = "&=";
  1119.  
  1120.   init_filename_times ();
  1121.  
  1122. #define UNSET_RESERVED_WORD(STRING) \
  1123.   do { is_reserved_word (STRING, sizeof (STRING) - 1)->name = ""; } while (0)
  1124.  
  1125.   if (! flag_handle_exceptions)
  1126.     {
  1127.       /* Easiest way to not reconize exception
  1128.      handling extenions...  */
  1129.       UNSET_RESERVED_WORD ("all");
  1130.       UNSET_RESERVED_WORD ("except");
  1131.       UNSET_RESERVED_WORD ("exception");
  1132.       UNSET_RESERVED_WORD ("raise");
  1133.       UNSET_RESERVED_WORD ("raises");
  1134.       UNSET_RESERVED_WORD ("reraise");
  1135.       UNSET_RESERVED_WORD ("try");
  1136.     }
  1137.   if (flag_no_asm)
  1138.     UNSET_RESERVED_WORD ("asm");
  1139.   if (flag_no_asm || flag_traditional)
  1140.     UNSET_RESERVED_WORD ("typeof");
  1141.   token_count = init_parse ();
  1142.   interface_unknown = 1;
  1143. }
  1144.  
  1145. void
  1146. reinit_parse_for_function ()
  1147. {
  1148.   current_base_init_list = NULL_TREE;
  1149.   current_member_init_list = NULL_TREE;
  1150. }
  1151.  
  1152. /* Functions and data structures for #pragma interface.
  1153.  
  1154.    `#pragma implementation' means that the main file being compiled
  1155.    is considered to implement (provide) the classes that appear in
  1156.    its main body.  I.e., if this is file "foo.cc", and class `bar'
  1157.    is defined in "foo.cc", then we say that "foo.cc implements bar".
  1158.  
  1159.    All main input files "implement" themselves automagically.
  1160.  
  1161.    `#pragma interface' means that unless this file (of the form "foo.h"
  1162.    is not presently being included by file "foo.cc", the
  1163.    CLASSTYPE_INTERFACE_ONLY bit gets set.  The effect is that none
  1164.    of the vtables nor any of the inline functions defined in foo.h
  1165.    will every be output.
  1166.  
  1167.    There are cases when we want to link files such as "defs.h" and
  1168.    "main.cc".  In this case, we give "defs.h" a `#pragma interface',
  1169.    and "main.cc" has `#pragma implementation "defs.h"'.  */
  1170.  
  1171. struct impl_files
  1172. {
  1173.   char *filename;
  1174.   struct impl_files *next;
  1175. };
  1176.  
  1177. static struct impl_files *impl_file_chain;
  1178.  
  1179. /* Helper function to load global variables with interface
  1180.    information.  */
  1181. static void
  1182. extract_interface_info ()
  1183. {
  1184.   tree fileinfo = get_time_identifier (input_filename);
  1185.   fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo);
  1186.   interface_only = TREE_INT_CST_LOW (fileinfo);
  1187.   interface_unknown = TREE_INT_CST_HIGH (fileinfo);
  1188. }
  1189.  
  1190. /* Return nonzero if S and T are not considered part of an
  1191.    INTERFACE/IMPLEMENTATION pair.  Otherwise, return 0.  */
  1192. static int
  1193. interface_strcmp (s)
  1194.      char *s;
  1195. {
  1196.   /* Set the interface/implementation bits for this scope.  */
  1197.   struct impl_files *ifiles;
  1198.   char *s1 = strrchr (s, '/');
  1199.   if (s1++ == 0)
  1200.     s1 = s;
  1201.   s = s1;
  1202.  
  1203.   for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
  1204.     {
  1205.       char *t1 = ifiles->filename;
  1206.       s1 = s;
  1207.  
  1208.       if (*s1 != *t1 || *s1 == 0)
  1209.     continue;
  1210.  
  1211.       while (*s1 == *t1 && *s1 != 0)
  1212.     s1++, t1++;
  1213.  
  1214.       /* A match.  */
  1215.       if (*s1 == *t1)
  1216.     return 0;
  1217.  
  1218.       /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc.  */
  1219.       if (strchr (s1, '.') || strchr (t1, '.'))
  1220.     continue;
  1221.  
  1222.       if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
  1223.     continue;
  1224.  
  1225.       /* A match.  */
  1226.       return 0;
  1227.     }
  1228.  
  1229.   /* No matches.  */
  1230.   return 1;
  1231. }
  1232.  
  1233. void
  1234. set_typedecl_interface_info (prev, vars)
  1235.      tree prev, vars;
  1236. {
  1237.   tree id = get_time_identifier (DECL_SOURCE_FILE (vars));
  1238.   tree fileinfo = IDENTIFIER_CLASS_VALUE (id);
  1239.   tree type = TREE_TYPE (vars);
  1240.  
  1241.   CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo)
  1242.     = interface_strcmp (DECL_SOURCE_FILE (vars));
  1243. }
  1244.  
  1245. void
  1246. set_vardecl_interface_info (prev, vars)
  1247.      tree prev, vars;
  1248. {
  1249. #if 0
  1250.   tree type = DECL_VPARENT (vars);
  1251. #else
  1252.   tree type = DECL_CONTEXT (vars);
  1253. #endif
  1254.  
  1255.   if (CLASSTYPE_INTERFACE_UNKNOWN (type) == 0)
  1256.     {
  1257.       if (CLASSTYPE_INTERFACE_ONLY (type))
  1258.     set_typedecl_interface_info (prev, TYPE_NAME (type));
  1259.       TREE_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type);
  1260.       TREE_PUBLIC (vars) = ! CLASSTYPE_INTERFACE_ONLY (type);
  1261.       CLASSTYPE_VTABLE_NEEDS_WRITING (type) |= TREE_PUBLIC (vars);
  1262.     }
  1263. }
  1264.  
  1265. /* Called from the top level: if there are any pending inlines to
  1266.    do, set up to process them now.  */
  1267. void
  1268. do_pending_inlines ()
  1269. {
  1270.   if (finput == finput1)
  1271.     {
  1272.       struct pending_inline *prev = 0, *tail;
  1273.       struct pending_inline *t =
  1274.     (struct pending_inline *) obstack_alloc (&inline_text_obstack,
  1275.                          sizeof (struct pending_inline));
  1276.  
  1277.       /* Record state we were in when we decided to process
  1278.      inline functions instead.  */
  1279.       t->next = pending_inlines;
  1280.       pending_inlines = t;
  1281.       t->lineno = lineno;
  1282.       t->filename = input_filename;
  1283.       t->fndecl = NULL_TREE;
  1284.       t->token = yychar;
  1285.       t->token_value = yylval.itype;
  1286.  
  1287.       /* Reverse the pending inline functions, since
  1288.      they were cons'd instead of appended.  */
  1289.  
  1290.       for (; t; t = tail)
  1291.     {
  1292.       tail = t->next;
  1293.       t->next = prev;
  1294.       prev = t;
  1295.     }
  1296.       pending_inlines = prev;
  1297.  
  1298.       /* Now start processing the first inline function.  */
  1299.       t = pending_inlines;
  1300.       pending_inlines = pending_inlines->next;
  1301.       finput = finput2;
  1302. #ifdef MASSCOMP
  1303.       setbuf (finput2, t->buf);
  1304.       finput2->_cnt = t->len-1;
  1305. #else
  1306. #if defined(i386) && !defined(sequent) && !defined(sun386)
  1307.       finput2->_ptr = finput2->_base = t->buf;
  1308.       _bufend(finput2) = t->buf + t->len;
  1309.       finput2->_flag = _IOFBF | _IOREAD;
  1310.       finput2->_cnt = t->len - 1;
  1311. #else
  1312. #ifndef hp9000s300
  1313. #ifdef USG_STDIO
  1314.       setvbuf(finput2,t->buf,_IOFBF,t->len);
  1315.       finput2->_cnt = t->len-1;
  1316. #else
  1317. #ifdef VMS
  1318.       setvbuf(finput2,t->buf,_IOFBF,t->len);
  1319.       (*finput2)->_cnt = t->len-1;
  1320. #else
  1321.       setbuffer (finput2, t->buf, t->len);
  1322.       finput2->_cnt = finput2->_bufsiz - 1;
  1323. #endif                /* VMS */
  1324. #endif                /* USG_STDIO */
  1325. #else
  1326.       setvbuf(finput2,t->buf,_IOFBF,t->len);
  1327.       finput2->_cnt = t->len-1;
  1328. #endif
  1329. #endif
  1330. #endif
  1331.       lineno = t->lineno;
  1332.       input_filename = t->filename;
  1333.       yychar = PRE_PARSED_FUNCTION_DECL;
  1334.       yylval.ttype = t->fndecl;
  1335.       if (flag_default_inline)
  1336.     TREE_INLINE (t->fndecl) = 1;
  1337.     }
  1338. }
  1339.  
  1340. /* Since inline methods can refer to text which has not yet been seen,
  1341.    we store the text of the method in a structure which is placed in the
  1342.    DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
  1343.    After parsing the body of the class definition, the FUNCTION_DECL's are
  1344.    scanned to see which ones have this field set.  Those are then digested
  1345.    one at a time.
  1346.  
  1347.    This function's FUNCTION_DECL will have a bit set in its common so
  1348.    that we know to watch out for it.  */
  1349.  
  1350. void
  1351. consume_string (this_obstack)
  1352.      register struct obstack *this_obstack;
  1353. {
  1354.   register char c;
  1355.   do
  1356.     {
  1357.       c = getc (finput);
  1358.       if (c == '\\')
  1359.     {
  1360.       obstack_1grow (this_obstack, c);
  1361.       c = getch ();
  1362.       obstack_1grow (this_obstack, c);
  1363.       continue;
  1364.     }
  1365.       if (c == '\n')
  1366.     {
  1367.       if (pedantic)
  1368.         warning ("ANSI C forbids newline in string constant");
  1369.       lineno++;
  1370.     }
  1371.       obstack_1grow (this_obstack, c);
  1372.     }
  1373.   while (c != '\"');
  1374. }
  1375.  
  1376. static int nextchar = -1;
  1377. static int nextyychar = -1;
  1378. static YYSTYPE nextyylval;
  1379. static tree nextlastiddecl;
  1380.  
  1381. /* Get input from stream.  When compiling under Cadillac,
  1382.    the bytes must be coaxed out via their read protocol.
  1383.    Otherwise, they come easily via standard input interface.  */
  1384. int
  1385. getch ()
  1386. {
  1387.   register int ch = getc (finput);
  1388.   return ch;
  1389. }
  1390.  
  1391. /* Return next non-whitespace input character, which may come
  1392.    from `finput', or from `nextchar'.  */
  1393. static int
  1394. yynextch ()
  1395. {
  1396.   int c;
  1397.  
  1398.   if (nextchar >= 0)
  1399.     {
  1400.       c = nextchar;
  1401.       nextchar = -1;
  1402.     }
  1403.   else c = getc (finput);
  1404.   return skip_white_space (c);
  1405. }
  1406.  
  1407. /* Unget character CH from the input stream.
  1408.    If RESCAN is non-zero, then we want to `see' this
  1409.    character as the next input token.  */
  1410. void
  1411. yyungetc (ch, rescan)
  1412.      int ch;
  1413.      int rescan;
  1414. {
  1415.   /* Unget a characater from the input stream.  */
  1416.   if (yychar == YYEMPTY || rescan == 0)
  1417.     ungetc (ch, finput);
  1418.   else
  1419.     {
  1420.       if (nextyychar >= 0)
  1421.     abort ();
  1422.       nextyychar = yychar;
  1423.       nextyylval = yylval;
  1424.       yychar = ch;
  1425.     }
  1426. }
  1427.  
  1428. void
  1429. reinit_parse_for_method (yychar, decl)
  1430.      int yychar;
  1431.      tree decl;
  1432. {
  1433.   register char c = 0;
  1434.   int blev = 1;
  1435.   tree fndecl = decl;
  1436.   int starting_lineno = lineno;
  1437.   char *starting_filename = input_filename;
  1438.   int len;
  1439.  
  1440.   if (yychar != '{')
  1441.     {
  1442.       if (yychar != ':' && yychar != RETURN)
  1443.     {
  1444.       yyerror ("parse error in method specification");
  1445.       yychar = '{';
  1446.     }
  1447.       obstack_1grow (&inline_text_obstack, yychar);
  1448.       while (c >= 0)
  1449.     {
  1450.       int this_lineno = lineno;
  1451.  
  1452.       c = yynextch ();
  1453.  
  1454.       /* Don't lose our cool if there are lots of comments.  */
  1455.       if (lineno - this_lineno)
  1456.         if (lineno - this_lineno == 1)
  1457.           obstack_1grow (&inline_text_obstack, '\n');
  1458.         else
  1459.           {
  1460.         char buf[12];
  1461.         sprintf (buf, "\n# %d \"", lineno);
  1462.         len = strlen (buf);
  1463.         obstack_grow (&inline_text_obstack, buf, len);
  1464.  
  1465.         len = strlen (input_filename);
  1466.         obstack_grow (&inline_text_obstack, input_filename, len);
  1467.         obstack_1grow (&inline_text_obstack, '\"');
  1468.         obstack_1grow (&inline_text_obstack, '\n');
  1469.           }
  1470.  
  1471.       /* strings must be read differently than text.  */
  1472.       if (c == '\"')
  1473.         {
  1474.           obstack_1grow (&inline_text_obstack, c);
  1475.           consume_string (&inline_text_obstack);
  1476.           c = yynextch ();
  1477.         }
  1478.       while (c > ' ')    /* ASCII dependent! */
  1479.         {
  1480.           obstack_1grow (&inline_text_obstack, c);
  1481.           if (c == '{') goto main_loop;
  1482.           if (c == '\"')
  1483.         consume_string (&inline_text_obstack);
  1484.           if (c == ';')
  1485.         {
  1486.           error ("function body for constructor missing");
  1487.           obstack_1grow (&inline_text_obstack, '{');
  1488.           obstack_1grow (&inline_text_obstack, '}');
  1489.           len += 2;
  1490.           goto done;
  1491.         }
  1492.           c = getch ();
  1493.         }
  1494.       if (c == '\n')
  1495.         lineno++;
  1496.       obstack_1grow (&inline_text_obstack, c);
  1497.     }
  1498.       if (c == EOF)
  1499.     {
  1500.       error_with_file_and_line (starting_filename,
  1501.                     starting_lineno,
  1502.                     "parse error in method specification");
  1503.     }      
  1504.     }
  1505.   else obstack_1grow (&inline_text_obstack, '{');
  1506.  
  1507.  main_loop:
  1508.   while (c >= 0)
  1509.     {
  1510.       int this_lineno = lineno;
  1511.  
  1512.       c = skip_white_space (getc (finput));
  1513.  
  1514.       /* Don't lose our cool if there are lots of comments.  */
  1515.       if (lineno - this_lineno)
  1516.     if (lineno - this_lineno == 1)
  1517.       obstack_1grow (&inline_text_obstack, '\n');
  1518.     else
  1519.       {
  1520.         char buf[12];
  1521.         sprintf (buf, "\n# %d \"", lineno);
  1522.         len = strlen (buf);
  1523.         obstack_grow (&inline_text_obstack, buf, len);
  1524.  
  1525.         len = strlen (input_filename);
  1526.         obstack_grow (&inline_text_obstack, input_filename, len);
  1527.         obstack_1grow (&inline_text_obstack, '\"');
  1528.         obstack_1grow (&inline_text_obstack, '\n');
  1529.       }
  1530.  
  1531.       while (c > ' ')
  1532.     {
  1533.       obstack_1grow (&inline_text_obstack, c);
  1534.       if (c == '{') blev++;
  1535.       else if (c == '}')
  1536.         {
  1537.           blev--;
  1538.           if (blev == 0)
  1539.         goto done;
  1540.         }
  1541.       else if (c == '\"')
  1542.         consume_string (&inline_text_obstack);
  1543.       c = getch ();
  1544.     }
  1545.       if (c == '\n')
  1546.     lineno++;
  1547.       obstack_1grow (&inline_text_obstack, c);
  1548.     }
  1549.  done:
  1550.   current_base_init_list = NULL_TREE;
  1551.   current_member_init_list = NULL_TREE;
  1552.  
  1553. #ifdef USG_STDIO
  1554.   len = obstack_object_size (&inline_text_obstack);
  1555.   /* If the buffer given to setvbuf is shorter than eight bytes long,
  1556.      setvbuf will (in violation of its man page) ignore the buffer
  1557.      and call malloc to get a bigger one.  */
  1558.   while (len < 8)
  1559.     {
  1560.       len++;
  1561.       obstack_1grow (&inline_text_obstack, ' ');
  1562.     }
  1563. #endif
  1564.  
  1565.   obstack_1grow (&inline_text_obstack, '\0');
  1566.   len = obstack_object_size (&inline_text_obstack);
  1567.  
  1568.   if (fndecl == void_type_node)
  1569.     {
  1570.       /* Happens when we get two declarations of the same
  1571.      function in the same scope.  */
  1572.       char *buf = obstack_base (&inline_text_obstack);
  1573.       obstack_free (&inline_text_obstack, buf);
  1574.       return;
  1575.     }
  1576.   else
  1577.     {
  1578.       struct pending_inline *t;
  1579.       char *buf = obstack_base (&inline_text_obstack);
  1580.  
  1581.       obstack_finish (&inline_text_obstack);
  1582.  
  1583.       t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
  1584.                            sizeof (struct pending_inline));
  1585.       t->buf = buf;
  1586.       t->len = len;
  1587.       t->lineno = starting_lineno;
  1588.       t->filename = starting_filename;
  1589.       t->token = YYEMPTY;
  1590.       DECL_PENDING_INLINE_INFO (fndecl) = t;
  1591.     }
  1592. }
  1593.  
  1594. /* Build a default function named NAME for type TYPE.
  1595.    KIND says what to build.  Currently only two kinds of default functions
  1596.    are recognized:
  1597.  
  1598.    When KIND == 0, build default X(X&) constructor.
  1599.    When KIND == 1, build default destructor.  */
  1600.  
  1601. tree
  1602. cons_up_default_function (type, name, kind)
  1603.      tree type, name;
  1604.      int kind;
  1605. {
  1606.   extern tree void_list_node;
  1607.   int len;
  1608.   tree fn, args;
  1609.   tree argtype;
  1610.  
  1611.   switch (kind)
  1612.     {
  1613.     case 0:
  1614.       /* Destructor.  */
  1615.       name = build_parse_node (BIT_NOT_EXPR, name);
  1616.       /* Fall through...  */
  1617.     case 2:
  1618.       /* Default constructor.  */
  1619.       args = void_list_node;
  1620.       break;
  1621.  
  1622.     case 3:
  1623.       type = build_type_variant (type, 1, 0);
  1624.       /* Fall through...  */
  1625.     case 1:
  1626.       argtype = build_reference_type (type);
  1627.       args = tree_cons (NULL_TREE,
  1628.             build_tree_list (hash_tree_chain (argtype, NULL_TREE),
  1629.                      get_identifier ("arg")),
  1630.             void_list_node);
  1631.       break;
  1632.  
  1633.     default:
  1634.       abort ();
  1635.     }
  1636.  
  1637.   fn = start_method (NULL_TREE,
  1638.              build_parse_node (CALL_EXPR, name, args, NULL_TREE),
  1639.              NULL_TREE);
  1640.   if (fn == void_type_node)
  1641.     return fn;
  1642.  
  1643.   obstack_1grow (&inline_text_obstack, '{');
  1644.   obstack_1grow (&inline_text_obstack, '}');
  1645. #ifdef USG_STDIO
  1646.   len = 2;
  1647.   while (len++ < 8)
  1648.     obstack_1grow (&inline_text_obstack, ' ');
  1649. #endif
  1650.  
  1651.   obstack_1grow (&inline_text_obstack, '\0');
  1652.   current_base_init_list = NULL_TREE;
  1653.   current_member_init_list = NULL_TREE;
  1654.  
  1655.   len = obstack_object_size (&inline_text_obstack);
  1656.  
  1657.   {
  1658.     struct pending_inline *t;
  1659.     char *buf = obstack_base (&inline_text_obstack);
  1660.  
  1661.     obstack_finish (&inline_text_obstack);
  1662.  
  1663.     t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
  1664.                          sizeof (struct pending_inline));
  1665.     t->buf = buf;
  1666.     t->len = len;
  1667.     t->lineno = lineno;
  1668.     t->filename = input_filename;
  1669.     t->token = YYEMPTY;
  1670.     DECL_PENDING_INLINE_INFO (fn) = t;
  1671.     /* We make this declaration private (static in the C sense).  */
  1672.     TREE_PUBLIC (fn) = 0;
  1673.   }
  1674.   finish_method (fn);
  1675.   DECL_COMPILER_GENERATED_P (fn) = 1;
  1676.   return fn;
  1677. }
  1678.  
  1679. /* Heuristic to tell whether the user is missing a semicolon
  1680.    after a struct or enum declaration.  Emit an error message
  1681.    if we know the user has blown it.  */
  1682. void
  1683. check_for_missing_semicolon (type)
  1684.      tree type;
  1685. {
  1686.   if (yychar < 0)
  1687.     yychar = yylex ();
  1688.  
  1689.   if (yychar > 255
  1690.       && yychar != IDENTIFIER
  1691.       && yychar != TYPENAME)
  1692.     {
  1693.       if (ANON_AGGRNAME_P (DECL_NAME (TYPE_NAME (type))))
  1694.     error ("semicolon missing after %s declaration",
  1695.            TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
  1696.       else
  1697.     error ("semicolon missing after declaration of `%s'",
  1698.            TYPE_NAME_STRING (type));
  1699.       shadow_tag (build_tree_list (0, type));
  1700.     }
  1701.   /* Could probably also hack cases where class { ... } f (); appears.  */
  1702. }
  1703.  
  1704. void
  1705. note_got_semicolon (type)
  1706.      tree type;
  1707. {
  1708.   if (IS_AGGR_TYPE (type))
  1709.     CLASSTYPE_GOT_SEMICOLON (type) = 1;
  1710. }
  1711.  
  1712. /* If C is not whitespace, return C.
  1713.    Otherwise skip whitespace and return first nonwhite char read.  */
  1714.  
  1715. static int
  1716. skip_white_space (c)
  1717.      register int c;
  1718. {
  1719. #if 0
  1720.   register int inside;
  1721. #endif
  1722.  
  1723.   for (;;)
  1724.     {
  1725.       switch (c)
  1726.     {
  1727.       /* Don't recognize comments in cc1: all comments are removed by cpp,
  1728.          and cpp output can include / and * consecutively as operators.  */
  1729. #if 0
  1730.     case '/':
  1731.       c = getc (finput);
  1732.       if (c != '*' && c != '/')
  1733.         {
  1734.           ungetc (c, finput);
  1735.           return '/';
  1736.         }
  1737.  
  1738.       if (c == '/')
  1739.         {
  1740.           while (c != EOF)
  1741.         {
  1742.           c = getch ();
  1743.           if (c == '\n')
  1744.             {
  1745.               ungetc (c, finput);
  1746.               break;
  1747.             }
  1748.         }
  1749.           if (c == EOF)
  1750.         {
  1751.           error ("unterminated comment");
  1752.           return EOF;
  1753.         }
  1754.           c = getch ();
  1755.           break;
  1756.         }
  1757.  
  1758.       c = getch ();
  1759.  
  1760.       inside = 1;
  1761.       while (inside)
  1762.         {
  1763.           if (c == '*')
  1764.         {
  1765.           while (c == '*')
  1766.             c = getch ();
  1767.  
  1768.           if (c == '/')
  1769.             {
  1770.               inside = 0;
  1771.               c = getch ();
  1772.             }
  1773.         }
  1774.           else if (c == '\n')
  1775.         {
  1776.           lineno++;
  1777.           c = getch ();
  1778.         }
  1779.           else if (c == EOF)
  1780.         {
  1781.           error ("unterminated comment");
  1782.           break;
  1783.         }
  1784.           else
  1785.         c = getch ();
  1786.         }
  1787.  
  1788.       break;
  1789. #endif
  1790.  
  1791.     case '\n':
  1792.       c = check_newline ();
  1793.       break;
  1794.  
  1795.     case ' ':
  1796.     case '\t':
  1797.     case '\f':
  1798.     case '\r':
  1799.     case '\v':
  1800.     case '\b':
  1801.       do
  1802.         c = getc (finput);
  1803.       while (c == ' ' || c == '\t');
  1804.       break;
  1805.  
  1806.     case '\\':
  1807.       c = getch ();
  1808.       if (c == '\n')
  1809.         lineno++;
  1810.       else
  1811.         error ("stray '\\' in program");
  1812.       c = getch ();
  1813.       break;
  1814.  
  1815.     default:
  1816.       return (c);
  1817.     }
  1818.     }
  1819. }
  1820.  
  1821.  
  1822.  
  1823. /* Make the token buffer longer, preserving the data in it.
  1824.    P should point to just beyond the last valid character in the old buffer.
  1825.    The value we return is a pointer to the new buffer
  1826.    at a place corresponding to P.  */
  1827.  
  1828. static char *
  1829. extend_token_buffer (p)
  1830.      char *p;
  1831. {
  1832.   int offset = p - token_buffer;
  1833.  
  1834.   maxtoken = maxtoken * 2 + 10;
  1835.   token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
  1836.  
  1837.   return token_buffer + offset;
  1838. }
  1839.  
  1840. #ifndef MERGED
  1841. /* This includes code from write_segment, stolen from unexec.c */
  1842.  
  1843. void dump_data()
  1844. {
  1845.   int new;
  1846.   register caddr_t ptr, end;
  1847.   register int i, nwrite, ret;
  1848.   char buf[80];
  1849.   extern int errno;
  1850.   char zeros[128];
  1851.  
  1852.   extern int been_here_before, just_done_unexec, my_edata;
  1853.   extern char *dump_source_name;
  1854.   extern char *asm_file_name, previous_asm_file_name[];
  1855.   char dump_file_name[256];    /* Fixed-sized buffer -- sigh. */
  1856.   caddr_t end_of_data, end_of_heap;
  1857.   int data_size, token;
  1858.   register int c;
  1859.  
  1860.   bzero (zeros, sizeof zeros);
  1861.  
  1862.   /* Here we have just seen `#pragma dump '.
  1863.      The name to dump to, a string constant, may follow.  */
  1864.  
  1865.   do
  1866.     c = getch ();
  1867.   while (c == ' ' || c == '\t');
  1868.  
  1869.   /* If no argument, default to something like "dumped-cc1plus".  */
  1870.   if (c == '\n')
  1871.     {
  1872.       char *tmp;
  1873.       strcpy (dump_file_name, "dumped-");
  1874.       if (tmp = strrchr (dump_source_name, '/'))
  1875.     dump_source_name = tmp + 1;
  1876.       strcat (dump_file_name, dump_source_name);
  1877.     }
  1878.   else
  1879.     {
  1880.       ungetc (c, finput);
  1881.       token = yylex ();
  1882.       if (token != STRING
  1883.       || TREE_CODE (yylval.ttype) != STRING_CST)
  1884.     {
  1885.       error ("invalid #pragma dump");
  1886.       return;
  1887.     }
  1888.  
  1889.       strcpy (dump_file_name, TREE_STRING_POINTER (yylval.ttype));
  1890.     }
  1891.  
  1892.   been_here_before = 1;        /* Raise the flag! */
  1893.   strcpy(previous_asm_file_name, asm_file_name);
  1894.   printf("\nDumping %s to %s...\n", dump_source_name, dump_file_name);
  1895.  
  1896.   end_of_heap = (caddr_t)sbrk(0);
  1897.   end_of_data = (caddr_t)((int)(&my_edata)&~(getpagesize()-1));
  1898.   data_size = (int)(end_of_heap-end_of_data);
  1899.   printf("Data size = %d\n", data_size);
  1900.           
  1901.   new = creat (dump_file_name, 0666);
  1902.  
  1903.   ptr = end_of_data;
  1904.   end = end_of_heap;
  1905.  
  1906.   for (i = 0; ptr < end;)
  1907.     {
  1908.       /* distance to next multiple of 128.  */
  1909.       nwrite = (((int) ptr + 128) & -128) - (int) ptr;
  1910.       /* But not beyond specified end.  */
  1911.       if (nwrite > end - ptr) nwrite = end - ptr;
  1912.       ret = write (new, ptr, nwrite);
  1913.       /* If write gets a page fault, it means we reached
  1914.      a gap between the old text segment and the old data segment.
  1915.      This gap has probably been remapped into part of the text segment.
  1916.      So write zeros for it.  */
  1917.       if (ret == -1 && errno == EFAULT)
  1918.     write (new, zeros, nwrite);
  1919.       else if (nwrite != ret)
  1920.     {
  1921.       sprintf (buf,
  1922.            "unexec write failure: addr 0x%x, fileno %d, size 0x%x, wrote 0x%x, errno %d",
  1923.            ptr, new, nwrite, ret, errno);
  1924.       perror (buf);
  1925.       return;
  1926.     }
  1927.       i += nwrite;
  1928.       ptr += nwrite;
  1929.     }
  1930.  
  1931.   close (new);
  1932.  
  1933.   just_done_unexec = 1;        /* Tell toplev not to output ending. */
  1934. }
  1935. #endif
  1936.  
  1937. static int
  1938. get_last_nonwhite_on_line ()
  1939. {
  1940.   register int c;
  1941.  
  1942.   /* Is this the last nonwhite stuff on the line?  */
  1943.   if (nextchar >= 0)
  1944.     c = nextchar, nextchar = -1;
  1945.   else
  1946.     c = getc (finput);
  1947.  
  1948.   while (c == ' ' || c == '\t')
  1949.     c = getc (finput);
  1950.   return c;
  1951. }
  1952.  
  1953. /* At the beginning of a line, increment the line number
  1954.    and process any #-directive on this line.
  1955.    If the line is a #-directive, read the entire line and return a newline.
  1956.    Otherwise, return the line's first non-whitespace character.  */
  1957.  
  1958. int
  1959. check_newline ()
  1960. {
  1961.   register int c;
  1962.   register int token;
  1963.  
  1964.   lineno++;
  1965.  
  1966.   /* Read first nonwhite char on the line.  */
  1967.  
  1968.   do
  1969.     c = getc (finput);
  1970.   while (c == ' ' || c == '\t');
  1971.  
  1972.   if (c != '#')
  1973.     {
  1974.       /* If not #, return it so caller will use it.  */
  1975.       return c;
  1976.     }
  1977.  
  1978.   /* Read first nonwhite char after the `#'.  */
  1979.  
  1980.   do
  1981.     c = getch ();
  1982.   while (c == ' ' || c == '\t');
  1983.  
  1984.   /* If a letter follows, then if the word here is `line', skip
  1985.      it and ignore it; otherwise, ignore the line, with an error
  1986.      if the word isn't `pragma'.  */
  1987.  
  1988.   if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
  1989.     {
  1990.       if (c == 'p')
  1991.     {
  1992.       if (getch () == 'r'
  1993.           && getch () == 'a'
  1994.           && getch () == 'g'
  1995.           && getch () == 'm'
  1996.           && getch () == 'a')
  1997. /* Change by Bryan Boreham, Kewill, Sun Jul 23 15:53:24 1989.
  1998.    This whole section added to support dumping of
  1999.    compilations in the middle. */
  2000.         {
  2001.           /* Read first nonwhite char after the `#pragma'.  */
  2002.  
  2003.           do
  2004.         c = getch ();
  2005.           while (c == ' ' || c == '\t');
  2006.  
  2007. #ifndef MERGED
  2008.           /* See if it is "dump" */
  2009.  
  2010.           if (c == 'd'
  2011.           && getch () == 'u'
  2012.           && getch () == 'm'
  2013.           && getch () == 'p'
  2014.           && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2015.         {
  2016. #ifdef VMS
  2017.             ;        /* Are you crazy? */
  2018. #else
  2019.           ungetc (c, finput);
  2020.           dump_data();
  2021.           longjmp (toplevel, 1);
  2022. #endif
  2023.         }
  2024.           else
  2025. #endif
  2026.         if (c == 'v'
  2027.                && getch () == 't'
  2028.                && getch () == 'a'
  2029.                && getch () == 'b'
  2030.                && getch () == 'l'
  2031.                && getch () == 'e'
  2032.                && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2033.         {
  2034.           extern tree pending_vtables;
  2035.  
  2036.           /* More follows: it must be a string constant (class name).  */
  2037.           token = yylex ();
  2038.           if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  2039.             {
  2040.               error ("invalid #pragma vtable");
  2041.               goto skipline;
  2042.             }
  2043.           if (write_virtuals != 2)
  2044.             {
  2045.               warning ("use `+e2' option to enable #pragma vtable");
  2046.               goto skipline;
  2047.             }
  2048.           pending_vtables = perm_tree_cons (NULL_TREE, get_identifier (TREE_STRING_POINTER (yylval.ttype)), pending_vtables);
  2049.           if (nextchar < 0)
  2050.             nextchar = getch ();
  2051.           c = nextchar;
  2052.           if (c != '\n')
  2053.             warning ("trailing characters ignored");
  2054.         }
  2055.           else if (c == 'u'
  2056.                && getch () == 'n'
  2057.                && getch () == 'i'
  2058.                && getch () == 't'
  2059.                && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2060.         {
  2061.           /* More follows: it must be a string constant (unit name).  */
  2062.           token = yylex ();
  2063.           if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  2064.             {
  2065.               error ("invalid #pragma unit");
  2066.               goto skipline;
  2067.             }
  2068.           current_unit_name = get_identifier (TREE_STRING_POINTER (yylval.ttype));
  2069.           current_unit_language = current_lang_name;
  2070.           if (nextchar < 0)
  2071.             nextchar = getch ();
  2072.           c = nextchar;
  2073.           if (c != '\n')
  2074.             warning ("trailing characters ignored");
  2075.         }
  2076.           else if (c == 'i')
  2077.         {
  2078.           tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
  2079.           c = getch ();
  2080.  
  2081.           if (c == 'n'
  2082.               && getch () == 't'
  2083.               && getch () == 'e'
  2084.               && getch () == 'r'
  2085.               && getch () == 'f'
  2086.               && getch () == 'a'
  2087.               && getch () == 'c'
  2088.               && getch () == 'e'
  2089.               && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2090.             {
  2091.               /* read to newline.  */
  2092.               while (c != '\n')
  2093.             c = getch ();
  2094.  
  2095.               write_virtuals = 3;
  2096.  
  2097.               if (impl_file_chain == 0)
  2098.             {
  2099.               char *filename;
  2100.               tree fi;
  2101.  
  2102.               /* If this is zero at this point, then we are
  2103.                  auto-implementing.  */
  2104.               if (main_input_filename == 0)
  2105.                 main_input_filename = input_filename;
  2106.  
  2107.               filename = strrchr (main_input_filename, '/');
  2108.               if (filename++ == 0)
  2109.                 filename = main_input_filename;
  2110.               fi = get_time_identifier (filename);
  2111.               fi = IDENTIFIER_CLASS_VALUE (fi);
  2112.               TREE_INT_CST_LOW (fi) = 0;
  2113.               TREE_INT_CST_LOW (fi) = 0;
  2114.               /* Get default.  */
  2115.               impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
  2116.               impl_file_chain->filename = filename;
  2117.               impl_file_chain->next = 0;
  2118.             }
  2119.  
  2120.               interface_only = interface_strcmp (input_filename);
  2121.               interface_unknown = 0;
  2122.               TREE_INT_CST_LOW (fileinfo) = interface_only;
  2123.               TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
  2124.             }
  2125.           else if (c == 'm'
  2126.                && getch () == 'p'
  2127.                && getch () == 'l'
  2128.                && getch () == 'e'
  2129.                && getch () == 'm'
  2130.                && getch () == 'e'
  2131.                && getch () == 'n'
  2132.                && getch () == 't'
  2133.                && getch () == 'a'
  2134.                && getch () == 't'
  2135.                && getch () == 'i'
  2136.                && getch () == 'o'
  2137.                && getch () == 'n'
  2138.                && ((c = getch ()) == ' ' || c == '\t' || c == '\n'))
  2139.             {
  2140.               char *main_filename = main_input_filename ? main_input_filename : input_filename;
  2141.               char *tmp;
  2142.  
  2143.               while (c == ' ' || c == '\t')
  2144.             c = getch ();
  2145.               if (c != '\n')
  2146.             {
  2147.               ungetc (c, finput);
  2148.               token = yylex ();
  2149.               if (token != STRING
  2150.                   || TREE_CODE (yylval.ttype) != STRING_CST)
  2151.                 {
  2152.                   error ("invalid `#pragma implementation'");
  2153.                   goto skipline;
  2154.                 }
  2155.               main_filename = TREE_STRING_POINTER (yylval.ttype);
  2156.             }
  2157.               tmp = strrchr (main_filename, '/');
  2158.               if (tmp++)
  2159.             main_filename = tmp;
  2160.  
  2161.               /* read to newline.  */
  2162.               while (c != '\n')
  2163.             c = getch ();
  2164.  
  2165.               if (write_virtuals == 3)
  2166.             {
  2167.               struct impl_files *ifiles = impl_file_chain;
  2168.               while (ifiles)
  2169.                 {
  2170.                   if (! strcmp (ifiles->filename, main_filename))
  2171.                 break;
  2172.                   ifiles = ifiles->next;
  2173.                 }
  2174.               if (ifiles == 0)
  2175.                 {
  2176.                   ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
  2177.                   ifiles->filename = main_filename;
  2178.                   ifiles->next = impl_file_chain;
  2179.                   impl_file_chain = ifiles;
  2180.                 }
  2181.             }
  2182.               else if (main_input_filename == input_filename
  2183.                    || ! strcmp (input_filename, main_filename))
  2184.             {
  2185.               write_virtuals = 3;
  2186.               if (impl_file_chain == 0)
  2187.                 {
  2188.                   impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
  2189.                   impl_file_chain->filename = main_filename;
  2190.                   impl_file_chain->next = 0;
  2191.                 }
  2192.             }
  2193.               else
  2194.             error ("`#pragma implementation' can only appear at top-level");
  2195.               interface_only = 0;
  2196.               interface_unknown = 0;
  2197.               TREE_INT_CST_LOW (fileinfo) = interface_only;
  2198.               TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
  2199.             }
  2200.         }
  2201.         }
  2202.       goto skipline;
  2203.     }
  2204.  
  2205.       else if (c == 'l')
  2206.     {
  2207.       if (getch () == 'i'
  2208.           && getch () == 'n'
  2209.           && getch () == 'e'
  2210.           && ((c = getch ()) == ' ' || c == '\t'))
  2211.         goto linenum;
  2212.     }
  2213.       else if (c == 'i')
  2214.     {
  2215.       if (getch () == 'd'
  2216.           && getch () == 'e'
  2217.           && getch () == 'n'
  2218.           && getch () == 't'
  2219.           && ((c = getch ()) == ' ' || c == '\t'))
  2220.         {
  2221.           /* Conditionally used.  */
  2222.               extern FILE *asm_out_file;
  2223.  
  2224.           if (pedantic)
  2225.         error ("ANSI C does not allow #ident");
  2226.  
  2227.           /* Here we have just seen `#ident '.
  2228.          A string constant should follow.  */
  2229.  
  2230.           while (c == ' ' || c == '\t')
  2231.         c = getch ();
  2232.  
  2233.           /* If no argument, ignore the line.  */
  2234.           if (c == '\n')
  2235.         return c;
  2236.  
  2237.           ungetc (c, finput);
  2238.           token = yylex ();
  2239.           if (token != STRING
  2240.           || TREE_CODE (yylval.ttype) != STRING_CST)
  2241.         {
  2242.           error ("invalid #ident");
  2243.           goto skipline;
  2244.         }
  2245.  
  2246. #ifdef ASM_OUTPUT_IDENT
  2247.           ASM_OUTPUT_IDENT (asm_out_file, TREE_STRING_POINTER (yylval.ttype));
  2248. #endif
  2249.  
  2250.           /* Skip the rest of this line.  */
  2251.           goto skipline;
  2252.         }
  2253.     }
  2254.       else if (c == 'n')
  2255.     {
  2256.       if (getch () == 'e'
  2257.           && getch () == 'w'
  2258.           && getch () == 'w'
  2259.           && getch () == 'o'
  2260.           && getch () == 'r'
  2261.           && getch () == 'l'
  2262.           && getch () == 'd'
  2263.           && ((c = getch ()) == ' ' || c == '\t'))
  2264.         {
  2265.           /* Used to test incremental compilation.  */
  2266.           sorry ("#pragma newworld");
  2267.           goto skipline;
  2268.         }
  2269.     }
  2270.       error ("undefined or invalid # directive");
  2271.       goto skipline;
  2272.     }
  2273.  
  2274. linenum:
  2275.   /* Here we have either `#line' or `# <nonletter>'.
  2276.      In either case, it should be a line number; a digit should follow.  */
  2277.  
  2278.   while (c == ' ' || c == '\t')
  2279.     c = getch ();
  2280.  
  2281.   /* If the # is the only nonwhite char on the line,
  2282.      just ignore it.  Check the new newline.  */
  2283.   if (c == '\n')
  2284.     return c;
  2285.  
  2286.   /* Something follows the #; read a token.  */
  2287.  
  2288.   ungetc (c, finput);
  2289.   token = yylex ();
  2290.  
  2291.   if (token == CONSTANT
  2292.       && TREE_CODE (yylval.ttype) == INTEGER_CST)
  2293.     {
  2294.       int old_lineno = lineno;
  2295.       /* subtract one, because it is the following line that
  2296.      gets the specified number */
  2297.  
  2298.       int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
  2299.       c = get_last_nonwhite_on_line ();
  2300.       if (c == '\n')
  2301.     {
  2302.       /* No more: store the line number and check following line.  */
  2303.       lineno = l;
  2304.       return c;
  2305.     }
  2306.       ungetc (c, finput);
  2307.  
  2308.       /* More follows: it must be a string constant (filename).  */
  2309.  
  2310.       token = yylex ();
  2311.       if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
  2312.     {
  2313.       error ("invalid #line");
  2314.       goto skipline;
  2315.     }
  2316.  
  2317.       /* Changing files again.  This means currently collected time
  2318.      is charged against header time, and body time starts back
  2319.      at 0.  */
  2320.       if (flag_detailed_statistics)
  2321.     {
  2322.       int this_time = my_gettime ();
  2323.       tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
  2324.       header_time += this_time - body_time;
  2325.       TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
  2326.         += this_time - body_time;
  2327.       this_filename_time = time_identifier;
  2328.       body_time = this_time;
  2329.     }
  2330.  
  2331.       input_filename
  2332.     = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
  2333.       strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
  2334.       lineno = l;
  2335. #ifdef FIELD_XREF
  2336.       FIELD_xref_file(input_filename);
  2337. #endif
  2338.  
  2339.       if (main_input_filename == 0)
  2340.     {
  2341.       extern int been_here_before;
  2342.       struct impl_files *ifiles = impl_file_chain;
  2343.  
  2344.       if (ifiles)
  2345.         {
  2346.           while (ifiles->next)
  2347.         ifiles = ifiles->next;
  2348.           ifiles->filename = (char *)strrchr (input_filename, '/');
  2349.           if (ifiles->filename++ == 0)
  2350.         ifiles->filename = input_filename;
  2351.         }
  2352.  
  2353.       main_input_filename = input_filename;
  2354.       if (write_virtuals == 3)
  2355.         walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info);
  2356.     }
  2357.  
  2358.       extract_interface_info ();
  2359.  
  2360.       c = get_last_nonwhite_on_line ();
  2361.       if (c == '\n')
  2362.     return c;
  2363.       ungetc (c, finput);
  2364.  
  2365.       token = yylex ();
  2366.  
  2367.       /* `1' after file name means entering new file.
  2368.      `2' after file name means just left a file.  */
  2369.  
  2370.       if (token == CONSTANT
  2371.       && TREE_CODE (yylval.ttype) == INTEGER_CST)
  2372.     {
  2373.       if (TREE_INT_CST_LOW (yylval.ttype) == 1)
  2374.         {
  2375.           struct file_stack *p
  2376.         = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  2377.           input_file_stack->line = old_lineno;
  2378.           p->next = input_file_stack;
  2379.           p->name = input_filename;
  2380.           input_file_stack = p;
  2381.           input_file_stack_tick++;
  2382.         }
  2383.       else if (input_file_stack->next)
  2384.         {
  2385.           struct file_stack *p = input_file_stack;
  2386.  
  2387.           input_file_stack = p->next;
  2388.           free (p);
  2389.           input_file_stack_tick++;
  2390.         }
  2391.       else
  2392.         error ("#-lines for entering and leaving files don't match");
  2393.     }
  2394.       /* If NEXTCHAR is not end of line, we don't care what it is.  */
  2395.       if (nextchar == '\n')
  2396.     return '\n';
  2397.     }
  2398.   else
  2399.     error ("invalid #-line");
  2400.  
  2401.   /* skip the rest of this line.  */
  2402.  skipline:
  2403.   if (c == '\n')
  2404.     return c;
  2405.   while ((c = getch ()) != EOF && c != '\n');
  2406.   return c;
  2407. }
  2408.  
  2409. #if 0
  2410. #define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0)
  2411. #define isdigit(char) (char >= '0' && char <= '9')
  2412. #else
  2413. #include <ctype.h>
  2414. #endif
  2415.  
  2416. #define ENDFILE -1  /* token that represents end-of-file */
  2417.  
  2418. static int
  2419. readescape ()
  2420. {
  2421.   register int c = getc (finput);
  2422.   register int count, code;
  2423.   int firstdig;
  2424.  
  2425.   switch (c)
  2426.     {
  2427.     case 'x':
  2428.       code = 0;
  2429.       count = 0;
  2430.       while (1)
  2431.     {
  2432.       c = getch ();
  2433.       if (! isxdigit (c))
  2434.         {
  2435.           ungetc (c, finput);
  2436.           break;
  2437.         }
  2438.       code *= 16;
  2439.       if (c >= 'a' && c <= 'f')
  2440.         code += c - 'a' + 10;
  2441.       if (c >= 'A' && c <= 'F')
  2442.         code += c - 'A' + 10;
  2443.       if (c >= '0' && c <= '9')
  2444.         code += c - '0';
  2445.       if (count == 0)
  2446.         firstdig = code;
  2447.       count++;
  2448.     }
  2449.       if (count == 0)
  2450.     error ("\\x used with no following hex digits");
  2451.       else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
  2452.            || ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
  2453.            <= firstdig))
  2454.     warning ("hex escape out of range");
  2455.       return code;
  2456.  
  2457.     case '0':  case '1':  case '2':  case '3':  case '4':
  2458.     case '5':  case '6':  case '7':
  2459.       code = 0;
  2460.       count = 0;
  2461.       while ((c <= '7') && (c >= '0') && (count++ < 3))
  2462.     {
  2463.       code = (code * 8) + (c - '0');
  2464.       c = getch ();
  2465.     }
  2466.       ungetc (c, finput);
  2467.       return code;
  2468.  
  2469.     case '\\': case '\'': case '"':
  2470.       return c;
  2471.  
  2472.     case '\n':
  2473.       lineno++;
  2474.       return -1;
  2475.  
  2476.     case 'n':
  2477.       return TARGET_NEWLINE;
  2478.  
  2479.     case 't':
  2480.       return TARGET_TAB;
  2481.  
  2482.     case 'r':
  2483.       return TARGET_CR;
  2484.  
  2485.     case 'f':
  2486.       return TARGET_FF;
  2487.  
  2488.     case 'b':
  2489.       return TARGET_BS;
  2490.  
  2491.     case 'a':
  2492.       return TARGET_BELL;
  2493.  
  2494.     case 'v':
  2495.       return TARGET_VT;
  2496.  
  2497.     case 'E':
  2498.       return 033;
  2499.  
  2500.     case '?':
  2501.       /* `\(', etc, are used at beginning of line to avoid confusing Emacs.  */
  2502.     case '(':
  2503.     case '{':
  2504.     case '[':
  2505.       return c;
  2506.     }
  2507.   if (c >= 040 && c <= 0177)
  2508.     warning ("unknown escape sequence `\\%c'", c);
  2509.   else
  2510.     warning ("unknown escape sequence: `\\' followed by char code 0x%x", c);
  2511.   return c;
  2512. }
  2513.  
  2514. /* Value is 1 if we should try to make the next identifier look like a
  2515.    typename (when it may be a local variable or a class variable).
  2516.    Value is 0 if we treat this name in a default fashion.
  2517.    Value is -1 if we must not see a type name.  */
  2518. int looking_for_typename = 0;
  2519.  
  2520. void
  2521. dont_see_typename ()
  2522. {
  2523.   looking_for_typename = -1;
  2524.   if (yychar == TYPENAME)
  2525.     {
  2526.       yychar = IDENTIFIER;
  2527.       lastiddecl = 0;
  2528.     }
  2529. }
  2530.  
  2531. void
  2532. see_typename ()
  2533. {
  2534.   looking_for_typename = 0;
  2535.   if (yychar == IDENTIFIER)
  2536.     {
  2537.       lastiddecl = lookup_name (yylval.ttype);
  2538.       if (lastiddecl == 0 && flag_labels_ok)
  2539.     lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
  2540.       else if (lastiddecl != 0
  2541.            && TREE_CODE (lastiddecl) == TYPE_DECL)
  2542.     yychar = TYPENAME;
  2543.     }
  2544. }
  2545.  
  2546. tree do_identifier (token)
  2547.      register tree token;
  2548. {
  2549.   register tree id = lastiddecl;
  2550.  
  2551.   if (yychar == YYEMPTY)
  2552.     yychar = yylex ();
  2553.   /* Scope class declarations before global
  2554.      declarations.  */
  2555.   if (id == IDENTIFIER_GLOBAL_VALUE (token)
  2556.       && current_class_type != 0
  2557.       && TYPE_SIZE (current_class_type) == 0)
  2558.     {
  2559.       /* Could be from one of the base classes.  */
  2560.       tree field = lookup_field (current_class_type, token, 1);
  2561.       if (field == 0)
  2562.     ;
  2563.       else if (field == error_mark_node)
  2564.     /* We have already generated the error message.
  2565.        But we still want to return this value.  */
  2566.     id = lookup_field (current_class_type, token, 0);
  2567.       else if (TREE_CODE (field) == VAR_DECL
  2568.            || TREE_CODE (field) == CONST_DECL)
  2569.     id = field;
  2570.       else if (TREE_CODE (field) != FIELD_DECL)
  2571.     abort ();
  2572.       else
  2573.     {
  2574.       error_with_decl (field, "invalid use of member `%s' from base class `%s'",
  2575.                TYPE_NAME_STRING (DECL_FIELD_CONTEXT (field)));
  2576.       id = error_mark_node;
  2577.       return id;
  2578.     }
  2579.     }
  2580.  
  2581.   if (!id || id == error_mark_node)
  2582.     {
  2583.       if (yychar == '(' || yychar == LEFT_RIGHT)
  2584.     {
  2585.       id = implicitly_declare (token);
  2586.       assemble_external (id);
  2587.       TREE_USED (id) = 1;
  2588.     }
  2589.       else if (current_function_decl == 0)
  2590.     {
  2591.       error ("`%s' undeclared, outside of functions",
  2592.          IDENTIFIER_POINTER (token));
  2593.       id = error_mark_node;
  2594.     }
  2595.       else
  2596.     {
  2597.       if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node
  2598.           || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
  2599.         {
  2600.           extern int undeclared_variable_notice;
  2601.  
  2602.           error ("`%s' undeclared (first use this function)",
  2603.              IDENTIFIER_POINTER (token));
  2604.  
  2605.           if (! undeclared_variable_notice)
  2606.         {
  2607.           error ("(Each undeclared identifier is reported only once");
  2608.           error ("for each function it appears in.)");
  2609.           undeclared_variable_notice = 1;
  2610.         }
  2611.         }
  2612.       id = error_mark_node;
  2613.       /* Prevent repeated error messages.  */
  2614.       IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node;
  2615.       SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
  2616.     }
  2617.     }
  2618.   /* TREE_USED is set in `hack_identifier'.  */
  2619.   if (TREE_CODE (id) == CONST_DECL)
  2620.     {
  2621.       if (IDENTIFIER_CLASS_VALUE (token) == id)
  2622.     {
  2623.       /* Check visibility.  */
  2624.       enum visibility_type visibility
  2625.         = compute_visibility (CLASSTYPE_AS_LIST (current_class_type), id);
  2626.       if (visibility == visibility_private)
  2627.         error_with_decl (id, "enum `%s' is private");
  2628.       /* protected is OK, since it's an enum of `this'.  */
  2629.     }
  2630.       id = DECL_INITIAL (id);
  2631.     }
  2632.   else id = hack_identifier (id, token, yychar);
  2633.   return id;
  2634. }
  2635.  
  2636. int
  2637. yylex ()
  2638. {
  2639.   tree tmp;
  2640.   register int c;
  2641.   register int value;
  2642.   int wide_flag = 0;
  2643.   int dollar_seen = 0;
  2644.  
  2645.  relex:
  2646.   if (nextyychar >= 0)
  2647.     {
  2648.       value = nextyychar;
  2649.       yylval = nextyylval;
  2650.       lastiddecl = nextlastiddecl;
  2651.       nextyychar = -1;
  2652.       if (value == IDENTIFIER)
  2653.     {
  2654.       tmp = yylval.ttype;
  2655.       goto resume_identifier_processing;
  2656.     }
  2657.       goto done;
  2658.     }
  2659.   if (nextchar >= 0)
  2660.     c = nextchar, nextchar = -1;
  2661.   else
  2662.     c = getc (finput);
  2663.  
  2664.   /* Effectively do c = skip_white_space (c)
  2665.      but do it faster in the usual cases.  */
  2666.   while (1)
  2667.     switch (c)
  2668.       {
  2669.       case ' ':
  2670.       case '\t':
  2671.       case '\f':
  2672.       case '\r':
  2673.       case '\v':
  2674.       case '\b':
  2675.     c = getc (finput);
  2676.     break;
  2677.  
  2678.       case '\n':
  2679.       case '/':
  2680.       case '\\':
  2681.     c = skip_white_space (c);
  2682.       default:
  2683.     goto found_nonwhite;
  2684.       }
  2685.  found_nonwhite:
  2686.  
  2687.   token_buffer[0] = c;
  2688.   token_buffer[1] = 0;
  2689.  
  2690. /*  yylloc.first_line = lineno; */
  2691.  
  2692.   switch (c)
  2693.     {
  2694.     case EOF:
  2695.       token_buffer[0] = '\0';
  2696.       if (pending_inlines)
  2697.     {
  2698.       struct pending_inline *t;
  2699.  
  2700.       t = pending_inlines;
  2701. #ifdef DO_METHODS_THE_OLD_WAY
  2702.       yylval.itype = t->token_value;
  2703.       value = t->token;
  2704. #else
  2705.       if (t->fndecl == 0)
  2706.         {
  2707.           yylval.itype = t->token_value;
  2708.           value = t->token;
  2709.         }
  2710.       else
  2711.         {
  2712.           yylval.ttype = t->fndecl;
  2713.           value = PRE_PARSED_FUNCTION_DECL;
  2714.         }
  2715. #endif
  2716.  
  2717.       lineno = t->lineno;
  2718. /*        yylloc.first_line = lineno; */
  2719.       input_filename = t->filename;
  2720.  
  2721.       if (t->next)
  2722.         {
  2723.           /* The buffer we used will be freed at the
  2724.          end of this function.  */
  2725.           pending_inlines = pending_inlines->next;
  2726. #ifdef MASSCOMP
  2727.           setbuf (finput2, t->buf);
  2728.           finput2->_cnt = t->len-1;
  2729. #else
  2730. #if defined(i386) && !defined(sequent) && !defined(sun386)
  2731.           finput2->_ptr = finput2->_base = t->buf;
  2732.           _bufend(finput2) = t->buf + t->len;
  2733.           finput2->_flag = _IOFBF | _IOREAD;
  2734.           finput2->_cnt = t->len - 1;
  2735. #else
  2736. #ifndef hp9000s300
  2737. #ifdef USG_STDIO
  2738.                 setvbuf(finput2,t->buf,_IOFBF,t->len);
  2739.                  finput2->_cnt = t->len-1;
  2740. #else
  2741. #ifdef VMS
  2742.                 setvbuf(finput2,t->buf,_IOFBF,t->len);
  2743.                  (*finput2)->_cnt = t->len-1;
  2744. #else
  2745.             setbuffer (finput2, t->buf, t->len);
  2746.             finput2->_cnt = finput2->_bufsiz - 1;
  2747. #endif                /* VMS */
  2748. #endif                /* USG_STDIO */
  2749. #else
  2750.                 setvbuf(finput2,t->buf,_IOFBF,t->len);
  2751.                  finput2->_cnt = t->len-1;
  2752. #endif
  2753. #endif
  2754. #endif
  2755.         }
  2756.       else
  2757.         {
  2758.           pending_inlines = NULL;
  2759.           finput = finput1;
  2760.           obstack_free (&inline_text_obstack, inline_text_firstobj);
  2761.         }
  2762.       /* The space used by T will be freed after all inline
  2763.          functions have been processed.  */
  2764.       if (value <= 0)
  2765.         goto relex;
  2766.       else
  2767.         goto done;
  2768.     }
  2769.       end_of_file = 1;
  2770.       value = ENDFILE;
  2771.       break;
  2772.  
  2773.     case '$':
  2774.       if (dollars_in_ident)
  2775.     {
  2776.       dollar_seen = 1;
  2777.       goto letter;
  2778.     }
  2779.       value = '$';
  2780.       goto done;
  2781.  
  2782.     case 'L':
  2783.       /* Capital L may start a wide-string or wide-character constant.  */
  2784.       {
  2785.     register int c = getch ();
  2786.     if (c == '\'')
  2787.       {
  2788.         wide_flag = 1;
  2789.         goto char_constant;
  2790.       }
  2791.     if (c == '"')
  2792.       {
  2793.         wide_flag = 1;
  2794.         goto string_constant;
  2795.       }
  2796.     ungetc (c, finput);
  2797.       }
  2798.  
  2799.     case 'A':  case 'B':  case 'C':  case 'D':  case 'E':
  2800.     case 'F':  case 'G':  case 'H':  case 'I':  case 'J':
  2801.     case 'K':          case 'M':  case 'N':  case 'O':
  2802.     case 'P':  case 'Q':  case 'R':  case 'S':  case 'T':
  2803.     case 'U':  case 'V':  case 'W':  case 'X':  case 'Y':
  2804.     case 'Z':
  2805.     case 'a':  case 'b':  case 'c':  case 'd':  case 'e':
  2806.     case 'f':  case 'g':  case 'h':  case 'i':  case 'j':
  2807.     case 'k':  case 'l':  case 'm':  case 'n':  case 'o':
  2808.     case 'p':  case 'q':  case 'r':  case 's':  case 't':
  2809.     case 'u':  case 'v':  case 'w':  case 'x':  case 'y':
  2810.     case 'z':
  2811.     case '_':
  2812.     letter:
  2813.       {
  2814.     register char *p;
  2815.  
  2816.     p = token_buffer;
  2817.     while (isalnum(c) || (c == '_') || c == '$')
  2818.       {
  2819.         if (p >= token_buffer + maxtoken)
  2820.           p = extend_token_buffer (p);
  2821.         if (c == '$' && ! dollars_in_ident)
  2822.           break;
  2823.  
  2824.         *p++ = c;
  2825.         c = getc (finput);
  2826.       }
  2827.  
  2828.     *p = 0;
  2829.     nextchar = c;
  2830.  
  2831.     value = IDENTIFIER;
  2832.     yylval.itype = 0;
  2833.  
  2834.       /* Try to recognize a keyword.  Uses minimum-perfect hash function */
  2835.  
  2836.     {
  2837.       register struct resword *ptr;
  2838.  
  2839.       if (ptr = is_reserved_word (token_buffer, p - token_buffer))
  2840.         {
  2841.           if (current_lang_name != lang_name_cplusplus)
  2842.         {
  2843.           if (ptr->rid != 0
  2844.               && (ptr->rid == RID_CLASS
  2845.               || ptr->rid == RID_FRIEND
  2846.               || ptr->rid == RID_VIRTUAL
  2847.               || (flag_no_asm && ptr->rid == RID_INLINE)))
  2848.             {
  2849.               ptr = 0;
  2850.               goto not_reserved_word_after_all;
  2851.             }
  2852.           if (flag_traditional
  2853.               && ((int) ptr->token == TYPEOF
  2854.               || ptr->rid == RID_SIGNED
  2855.               || ptr->rid == RID_INLINE))
  2856.             {
  2857.               ptr = 0;
  2858.               goto not_reserved_word_after_all;
  2859.             }  
  2860.         }
  2861.           if (ptr->rid)
  2862.         {
  2863.           tree old_ttype = ridpointers[(int) ptr->rid];
  2864.  
  2865.           /* If this provides a type for us, then revert lexical
  2866.              state to standard state.  */
  2867.           if (TREE_CODE (old_ttype) == IDENTIFIER_NODE
  2868.               && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0
  2869.               && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
  2870.             looking_for_typename = 0;
  2871.  
  2872.           /* Check if this is a language-type declaration.
  2873.              Just glimpse the next non-white character.  */
  2874.           nextchar = skip_white_space (nextchar);
  2875.           if (nextchar == '"')
  2876.             {
  2877.               /* We are looking at a string.  Complain
  2878.              if the token before the string is no `extern'.
  2879.              
  2880.              Could cheat some memory by placing this string
  2881.              on the temporary_, instead of the saveable_
  2882.              obstack.  */
  2883.  
  2884.               if (ptr->rid != RID_EXTERN)
  2885.             error ("invalid modifier `%s' for language string",
  2886.                    ptr->name);
  2887.               yylex ();
  2888.               value = EXTERN_LANG_STRING;
  2889.               yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype));
  2890.               break;
  2891.             }
  2892.           yylval.ttype = old_ttype;
  2893.         }
  2894.           value = (int) ptr->token;
  2895.         }
  2896.       not_reserved_word_after_all:
  2897.       ;
  2898.     }
  2899.  
  2900.     /* If we did not find a keyword, look for an identifier
  2901.        (or a typename).  */
  2902.  
  2903. #ifdef FIELD_XREF
  2904.     if (value == IDENTIFIER || value == TYPESPEC)
  2905.       FIELD_xref_ref(current_function_decl,token_buffer);
  2906. #endif
  2907.     if (value == IDENTIFIER)
  2908.       {
  2909.         tmp = get_identifier (token_buffer);
  2910. #ifndef VMS
  2911.         /* Make sure that user does not collide with our internal
  2912.            naming scheme.  */
  2913.         if (JOINER == '$'
  2914.         && dollar_seen
  2915.         && (THIS_NAME_P (tmp)
  2916.             || VPTR_NAME_P (tmp)
  2917.             || DESTRUCTOR_NAME_P (tmp)
  2918.             || WRAPPER_OR_ANTI_WRAPPER_NAME_P (tmp)
  2919.             || OPERATOR_NAME_P (tmp)
  2920.             || VTABLE_NAME_P (tmp)
  2921.             || OPERATOR_TYPENAME_P (tmp)
  2922.             || TEMP_NAME_P (tmp)
  2923.             || ANON_AGGRNAME_P (tmp)
  2924.             || ANON_PARMNAME_P (tmp)))
  2925.           warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
  2926.                token_buffer);
  2927. #endif
  2928.  
  2929.         /* Come into here if we must reprocess an identifier.  */
  2930.       resume_identifier_processing:
  2931.  
  2932.         if (looking_for_typename == 1
  2933.         && TREE_TYPE (tmp) != 0)
  2934.           lastiddecl = TREE_TYPE (tmp);
  2935.         else lastiddecl = lookup_name (tmp);
  2936.  
  2937.         if (lastiddecl && TREE_CODE (lastiddecl) == TYPE_DECL
  2938.         && looking_for_typename >= 0)
  2939.           {
  2940.         /* This call could blow away yylval.  */
  2941.  
  2942.         c = skip_white_space (nextchar);
  2943.         if (c == ':')
  2944.           {
  2945.             c = getch ();
  2946.             if (c == ':')
  2947.               {
  2948.             nextchar = -1;
  2949.             value = TYPENAME_SCOPE;
  2950.               }
  2951.             else
  2952.               {
  2953.             nextchar = c;
  2954.             value = TYPENAME_COLON;
  2955.               }
  2956.           }
  2957.         else if (c == '.'
  2958.              && current_function_decl == NULL_TREE
  2959.              && current_class_type == NULL_TREE)
  2960.           {
  2961.             c = getch ();
  2962.             if (c == '.')
  2963.               {
  2964.             nextchar = -1;
  2965.             c = getch ();
  2966.             if (c != '.')
  2967.               error ("missing '.' in `...'");
  2968.             value = TYPENAME_ELLIPSIS;
  2969.             tmp = build_tree_list (NULL_TREE, build_tree_list (TREE_TYPE (lastiddecl), NULL_TREE));
  2970.               }
  2971.             else
  2972.               {
  2973.             nextchar = c;
  2974.             warning ("use of obsolete scope operator `.'; use `::' instead");
  2975.             value = TYPENAME_SCOPE;
  2976.               }
  2977.             looking_for_typename = 0;
  2978.           }
  2979.         else
  2980.           {
  2981.             nextchar = c;
  2982.             value = TYPENAME;
  2983.             if (looking_for_typename == 1)
  2984.               {
  2985.             looking_for_typename = 0;
  2986. #if 0
  2987.             yylval.ttype = TREE_TYPE (lastiddecl);
  2988.             break;
  2989. #endif
  2990.               }
  2991.           }
  2992.           }
  2993.         else if (lastiddecl == 0 && flag_labels_ok)
  2994.           lastiddecl = IDENTIFIER_LABEL_VALUE (tmp);
  2995.  
  2996.         yylval.ttype = tmp;
  2997.       }
  2998.     if (value == NEW && ! global_bindings_p ())
  2999.       {
  3000.         looking_for_typename = 1;
  3001.         value = NEW;
  3002.         goto done;
  3003.       }
  3004.       }
  3005.       break;
  3006.  
  3007.     case '0':  case '1':  case '2':  case '3':  case '4':
  3008.     case '5':  case '6':  case '7':  case '8':  case '9':
  3009.     case '.':
  3010.       {
  3011.     register char *p;
  3012.     int base = 10;
  3013.     int count = 0;
  3014.     int largest_digit = 0;
  3015.     int numdigits = 0;
  3016.     /* for multi-precision arithmetic,
  3017.        we store only 8 live bits in each short,
  3018.        giving us 64 bits of reliable precision */
  3019.     short shorts[8];
  3020.  
  3021.     enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
  3022.       = NOT_FLOAT;
  3023.  
  3024.     p = token_buffer;
  3025.     *p++ = c;
  3026.  
  3027.     /* Optimize for most frequent case.  */
  3028.     if (c == '0' || c == '1')
  3029.       {
  3030.         register int c1 = getch ();
  3031.         if (! isalnum (c1) && c1 != '.')
  3032.           {
  3033.         /* Terminate string.  */
  3034.         *p = 0;
  3035.         if (c == '0')
  3036.           yylval.ttype = integer_zero_node;
  3037.         else
  3038.           yylval.ttype = integer_one_node;
  3039.         nextchar = c1;
  3040.         value = CONSTANT;
  3041.         goto done;
  3042.           }
  3043.         ungetc (c1, finput);
  3044.       }
  3045.  
  3046.     for (count = 0; count < 8; count++)
  3047.       shorts[count] = 0;
  3048.  
  3049.     if (c == '0')
  3050.       {
  3051.         *p++ = (c = getch ());
  3052.         if ((c == 'x') || (c == 'X'))
  3053.           {
  3054.         base = 16;
  3055.         *p++ = (c = getch ());
  3056.           }
  3057.         else
  3058.           {
  3059.         base = 8;
  3060.         numdigits++;
  3061.           }
  3062.       }
  3063.  
  3064.     /* Read all the digits-and-decimal-points.  */
  3065.  
  3066.     while (c == '.'
  3067.            || (isalnum (c) && (c != 'l') && (c != 'L')
  3068.            && (c != 'u') && (c != 'U')
  3069.            && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
  3070.       {
  3071.         if (c == '.')
  3072.           {
  3073.         if (base == 16)
  3074.           error ("floating constant may not be in radix 16");
  3075.         if (floatflag == AFTER_POINT)
  3076.           {
  3077.             error ("malformed floating constant");
  3078.             floatflag = TOO_MANY_POINTS;
  3079.           }
  3080.         else
  3081.           floatflag = AFTER_POINT;
  3082.  
  3083.         base = 10;
  3084.         *p++ = c = getch ();
  3085.         /* Accept '.' as the start of a floating-point number
  3086.            only when it is followed by a digit.
  3087.            Otherwise, unread the following non-digit
  3088.            and use the '.' as a structural token.  */
  3089.         if (p == token_buffer + 2 && !isdigit (c))
  3090.           {
  3091.             if (c == '.')
  3092.               {
  3093.             c = getch ();
  3094.             if (c == '.')
  3095.               {
  3096.                 *p++ = '.';
  3097.                 *p = '\0';
  3098.                 value = ELLIPSIS;
  3099.                 goto done;
  3100.               }
  3101.             nextchar = c;
  3102.             token_buffer[2] = '\0';
  3103.             value = RANGE;
  3104.             goto done;
  3105.               }
  3106.             nextchar = c;
  3107.             token_buffer[1] = '\0';
  3108.             value = '.';
  3109.             goto done;
  3110.           }
  3111.           }
  3112.         else
  3113.           {
  3114.         /* It is not a decimal point.
  3115.            It should be a digit (perhaps a hex digit).  */
  3116.  
  3117.         if (isdigit (c))
  3118.           {
  3119.             c = c - '0';
  3120.           }
  3121.         else if (base <= 10)
  3122.           {
  3123.             if ((c&~040) == 'E')
  3124.               {
  3125.             base = 10;
  3126.             floatflag = AFTER_POINT;
  3127.             break;   /* start of exponent */
  3128.               }
  3129.             error ("nondigits in number and not hexadecimal");
  3130.             c = 0;
  3131.           }
  3132.         else if (c >= 'a')
  3133.           {
  3134.             c = c - 'a' + 10;
  3135.           }
  3136.         else
  3137.           {
  3138.             c = c - 'A' + 10;
  3139.           }
  3140.         if (c >= largest_digit)
  3141.           largest_digit = c;
  3142.         numdigits++;
  3143.  
  3144.         for (count = 0; count < 8; count++)
  3145.           {
  3146.             (shorts[count] *= base);
  3147.             if (count)
  3148.               {
  3149.             shorts[count] += (shorts[count-1] >> 8);
  3150.             shorts[count-1] &= (1<<8)-1;
  3151.               }
  3152.             else shorts[0] += c;
  3153.           }
  3154.  
  3155.         if (p >= token_buffer + maxtoken - 3)
  3156.           p = extend_token_buffer (p);
  3157.         *p++ = (c = getch ());
  3158.           }
  3159.       }
  3160.  
  3161.     if (numdigits == 0)
  3162.       error ("numeric constant with no digits");
  3163.  
  3164.     if (largest_digit >= base)
  3165.       error ("numeric constant contains digits beyond the radix");
  3166.  
  3167.     /* Remove terminating char from the token buffer and delimit the string */
  3168.     *--p = 0;
  3169.  
  3170.     if (floatflag != NOT_FLOAT)
  3171.       {
  3172.         tree type = double_type_node;
  3173.         char f_seen = 0;
  3174.         char l_seen = 0;
  3175.         double value;
  3176.  
  3177.         /* Read explicit exponent if any, and put it in tokenbuf.  */
  3178.  
  3179.         if ((c == 'e') || (c == 'E'))
  3180.           {
  3181.         if (p >= token_buffer + maxtoken - 3)
  3182.           p = extend_token_buffer (p);
  3183.         *p++ = c;
  3184.         c = getch ();
  3185.         if ((c == '+') || (c == '-'))
  3186.           {
  3187.             *p++ = c;
  3188.             c = getch ();
  3189.           }
  3190.         if (! isdigit (c))
  3191.           error ("floating constant exponent has no digits");
  3192.             while (isdigit (c))
  3193.           {
  3194.             if (p >= token_buffer + maxtoken - 3)
  3195.               p = extend_token_buffer (p);
  3196.             *p++ = c;
  3197.             c = getch ();
  3198.           }
  3199.           }
  3200.  
  3201.         *p = 0;
  3202.         errno = 0;
  3203.         value = atof (token_buffer);
  3204. #ifdef ERANGE
  3205.         if (errno == ERANGE && !flag_traditional)
  3206.           {
  3207.         char *p1 = token_buffer;
  3208.         /* Check for "0.0" and variants;
  3209.            Sunos 4 spuriously returns ERANGE for them.  */
  3210.         while (*p1 == '0') p1++;
  3211.         if (*p1 == '.') p1++;
  3212.         while (*p1 == '0') p1++;
  3213.         if (*p1 != 0)
  3214.           warning ("floating point number exceeds range of `double'");
  3215.           }
  3216. #endif
  3217.  
  3218.         /* Read the suffixes to choose a data type.  */
  3219.         while (1)
  3220.           {
  3221.         if (c == 'f' || c == 'F')
  3222.           {
  3223.             if (f_seen)
  3224.               error ("two `f's in floating constant");
  3225.             f_seen = 1;
  3226.             type = float_type_node;
  3227.           }
  3228.         else if (c == 'l' || c == 'L')
  3229.           {
  3230.             if (l_seen)
  3231.               error ("two `l's in floating constant");
  3232.             l_seen = 1;
  3233.             type = long_double_type_node;
  3234.           }
  3235.         else
  3236.           {
  3237.             if (isalnum (c))
  3238.               {
  3239.             error ("garbage at end of number");
  3240.             while (isalnum (c))
  3241.               {
  3242.                 if (p >= token_buffer + maxtoken - 3)
  3243.                   p = extend_token_buffer (p);
  3244.                 *p++ = c;
  3245.                 c = getch ();
  3246.               }
  3247.               }
  3248.             break;
  3249.           }
  3250.         if (p >= token_buffer + maxtoken - 3)
  3251.           p = extend_token_buffer (p);
  3252.         *p++ = c;
  3253.         c = getch ();
  3254.           }
  3255.  
  3256.         /* Create a node with determined type and value.  */
  3257.         yylval.ttype = build_real (type, value);
  3258.  
  3259.         ungetc (c, finput);
  3260.         *p = 0;
  3261.       }
  3262.     else
  3263.       {
  3264.         tree type;
  3265.         int spec_unsigned = 0;
  3266.         int spec_long = 0;
  3267.  
  3268.         while (1)
  3269.           {
  3270.         if (c == 'u' || c == 'U')
  3271.           {
  3272.             if (spec_unsigned)
  3273.               error ("two `u's in integer constant");
  3274.             spec_unsigned = 1;
  3275.           }
  3276.         else if (c == 'l' || c == 'L')
  3277.           {
  3278.             if (spec_long)
  3279.               error ("two `l's in integer constant");
  3280.             spec_long = 1;
  3281.           }
  3282.         else
  3283.           {
  3284.             if (isalnum (c))
  3285.               {
  3286.             error ("garbage at end of number");
  3287.             while (isalnum (c))
  3288.               {
  3289.                 if (p >= token_buffer + maxtoken - 3)
  3290.                   p = extend_token_buffer (p);
  3291.                 *p++ = c;
  3292.                 c = getch ();
  3293.               }
  3294.               }
  3295.             break;
  3296.           }
  3297.         if (p >= token_buffer + maxtoken - 3)
  3298.           p = extend_token_buffer (p);
  3299.         *p++ = c;
  3300.         c = getch ();
  3301.           }
  3302.  
  3303.         ungetc (c, finput);
  3304.  
  3305.         if (shorts[7] | shorts[6] | shorts[5] | shorts[4])
  3306.           warning ("integer constant out of range");
  3307.  
  3308.         /* This is simplified by the fact that our constant
  3309.            is always positive.  */
  3310.         yylval.ttype
  3311.           = build_int_2 ((shorts[3]<<24) + (shorts[2]<<16) + (shorts[1]<<8) + shorts[0],
  3312.                  0);
  3313.  
  3314.         if (!spec_long && !spec_unsigned
  3315.         && int_fits_type_p (yylval.ttype, integer_type_node))
  3316.           type = integer_type_node;
  3317.  
  3318.         else if (!spec_long && base != 10
  3319.              && int_fits_type_p (yylval.ttype, unsigned_type_node))
  3320.           type = unsigned_type_node;
  3321.  
  3322.         else if (!spec_unsigned
  3323.              && int_fits_type_p (yylval.ttype, long_integer_type_node))
  3324.           type = long_integer_type_node;
  3325.  
  3326.         else
  3327.           {
  3328.         type = long_unsigned_type_node;
  3329.         if (! int_fits_type_p (yylval.ttype, long_unsigned_type_node))
  3330.           warning ("integer constant out of range");
  3331.           }
  3332.         TREE_TYPE (yylval.ttype) = type;
  3333.       }
  3334.  
  3335.     value = CONSTANT; break;
  3336.       }
  3337.  
  3338.     case '\'':
  3339.     char_constant:
  3340.       {
  3341.     register int result = 0;
  3342.     register num_chars = 0;
  3343.     int width = TYPE_PRECISION (char_type_node);
  3344.     int max_chars;
  3345.  
  3346.     if (wide_flag) width = TYPE_PRECISION (integer_type_node);
  3347.  
  3348.     max_chars = TYPE_PRECISION (integer_type_node) / width;
  3349.  
  3350.     while (1)
  3351.       {
  3352.       tryagain:
  3353.  
  3354.         c = getch ();
  3355.  
  3356.         if (c == '\'' || c == EOF)
  3357.           break;
  3358.  
  3359.         if (c == '\\')
  3360.           {
  3361.         c = readescape ();
  3362.         if (c < 0)
  3363.           goto tryagain;
  3364.         if (width < HOST_BITS_PER_INT
  3365.             && (unsigned) c >= (1 << width))
  3366.           warning ("escape sequence out of range for character");
  3367.           }
  3368.         else if (c == '\n')
  3369.           {
  3370.         if (pedantic)
  3371.           warning ("ANSI C forbids newline in character constant");
  3372.         lineno++;
  3373.           }
  3374.  
  3375.         num_chars++;
  3376.         if (num_chars > maxtoken - 4)
  3377.           extend_token_buffer (token_buffer);
  3378.  
  3379.         token_buffer[num_chars] = c;
  3380.  
  3381.         /* Merge character into result; ignore excess chars.  */
  3382.         if (num_chars < max_chars + 1)
  3383.           {
  3384.         if (width < HOST_BITS_PER_INT)
  3385.           result = (result << width) | (c & ((1 << width) - 1));
  3386.         else
  3387.           result = c;
  3388.           }
  3389.       }
  3390.  
  3391.     token_buffer[num_chars + 1] = '\'';
  3392.     token_buffer[num_chars + 2] = 0;
  3393.  
  3394.     if (c != '\'')
  3395.       error ("malformatted character constant");
  3396.     else if (num_chars == 0)
  3397.       error ("empty character constant");
  3398.     else if (num_chars > max_chars)
  3399.       {
  3400.         num_chars = max_chars;
  3401.         error ("character constant too long");
  3402.       }
  3403.     else if (num_chars != 1 && ! flag_traditional)
  3404.       warning ("multi-character character constant");
  3405.  
  3406.     /* If char type is signed, sign-extend the constant.  */
  3407.     if (! wide_flag)
  3408.       {
  3409.         int num_bits = num_chars * width;
  3410.         if (TREE_UNSIGNED (char_type_node)
  3411.         || ((result >> (num_bits - 1)) & 1) == 0)
  3412.           yylval.ttype
  3413.         = build_int_2 (result & ((unsigned) ~0
  3414.                      >> (HOST_BITS_PER_INT - num_bits)),
  3415.                    0);
  3416.         else
  3417.           yylval.ttype
  3418.         = build_int_2 (result | ~((unsigned) ~0
  3419.                       >> (HOST_BITS_PER_INT - num_bits)),
  3420.                    -1);
  3421.         TREE_TYPE (yylval.ttype) = char_type_node;
  3422.       }
  3423.     else
  3424.       {
  3425.         yylval.ttype = build_int_2 (result, 0);
  3426.         TREE_TYPE (yylval.ttype) = integer_type_node;
  3427.       }
  3428.     value = CONSTANT; break;
  3429.       }
  3430.  
  3431.     case '"':
  3432.     string_constant:
  3433.       {
  3434.     int *widep;
  3435.     register char *p;
  3436.  
  3437.     c = getch ();
  3438.     p = token_buffer + 1;
  3439.  
  3440.     if (wide_flag)
  3441.       widep = wide_buffer;
  3442.  
  3443.     while (c != '"' && c >= 0)
  3444.       {
  3445.         if (c == '\\')
  3446.           {
  3447.         c = readescape ();
  3448.         if (c < 0)
  3449.           goto skipnewline;
  3450.         if (!wide_flag && c >= (1 << BITS_PER_UNIT))
  3451.           warning ("escape sequence out of range for character");
  3452.           }
  3453.         else if (c == '\n')
  3454.           {
  3455.         if (pedantic)
  3456.           warning ("ANSI C forbids newline in string constant");
  3457.         lineno++;
  3458.           }
  3459.  
  3460.         /* Store the char in C into the appropriate buffer.  */
  3461.  
  3462.         if (wide_flag)
  3463.           {
  3464.         if (widep == wide_buffer + max_wide)
  3465.           {
  3466.             int n = widep - wide_buffer;
  3467.             max_wide *= 2;
  3468.             wide_buffer = (int *) xrealloc (wide_buffer, max_wide + 1);
  3469.             widep = wide_buffer + n;
  3470.           }
  3471.         *widep++ = c;
  3472.           }
  3473.         else
  3474.           {
  3475.         if (p == token_buffer + maxtoken)
  3476.           p = extend_token_buffer (p);
  3477.         *p++ = c;
  3478.           }
  3479.  
  3480.       skipnewline:
  3481.         c = getch ();
  3482.         if (c == EOF) {
  3483.         error("Unterminated string");
  3484.         break;
  3485.         }
  3486.       }
  3487.  
  3488.     /* We have read the entire constant.
  3489.        Construct a STRING_CST for the result.  */
  3490.  
  3491.     if (wide_flag)
  3492.       {
  3493.         /* If this is a L"..." wide-string, make a vector
  3494.            of the ints in wide_buffer.  */
  3495.         *widep = 0;
  3496.         /* We have not implemented the case where `int'
  3497.            on the target and on the execution machine differ in size.  */
  3498.         assert (TYPE_PRECISION (integer_type_node) == sizeof (int) * BITS_PER_UNIT);
  3499.         yylval.ttype = build_string ((widep - wide_buffer) * sizeof (int),
  3500.                      (char *)wide_buffer);
  3501.         TREE_TYPE (yylval.ttype) = int_array_type_node;
  3502.       }
  3503.     else
  3504.       {
  3505.         *p = 0;
  3506.         yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
  3507.         TREE_TYPE (yylval.ttype) = char_array_type_node;
  3508.       }
  3509.  
  3510.     *p++ = '"';
  3511.     *p = 0;
  3512.  
  3513.     value = STRING; break;
  3514.       }
  3515.  
  3516.     case '+':
  3517.     case '-':
  3518.     case '&':
  3519.     case '|':
  3520.     case '<':
  3521.     case '>':
  3522.     case '*':
  3523.     case '/':
  3524.     case '%':
  3525.     case '^':
  3526.     case '!':
  3527.     case '=':
  3528.       {
  3529.     register int c1;
  3530.  
  3531.       combine:
  3532.  
  3533.     switch (c)
  3534.       {
  3535.       case '+':
  3536.         yylval.code = PLUS_EXPR; break;
  3537.       case '-':
  3538.         yylval.code = MINUS_EXPR; break;
  3539.       case '&':
  3540.         yylval.code = BIT_AND_EXPR; break;
  3541.       case '|':
  3542.         yylval.code = BIT_IOR_EXPR; break;
  3543.       case '*':
  3544.         yylval.code = MULT_EXPR; break;
  3545.       case '/':
  3546.         yylval.code = TRUNC_DIV_EXPR; break;
  3547.       case '%':
  3548.         yylval.code = TRUNC_MOD_EXPR; break;
  3549.       case '^':
  3550.         yylval.code = BIT_XOR_EXPR; break;
  3551.       case LSHIFT:
  3552.         yylval.code = LSHIFT_EXPR; break;
  3553.       case RSHIFT:
  3554.         yylval.code = RSHIFT_EXPR; break;
  3555.       case '<':
  3556.         yylval.code = LT_EXPR; break;
  3557.       case '>':
  3558.         yylval.code = GT_EXPR; break;
  3559.       }
  3560.  
  3561.     token_buffer[1] = c1 = getch ();
  3562.     token_buffer[2] = 0;
  3563.  
  3564.     if (c1 == '=')
  3565.       {
  3566.         switch (c)
  3567.           {
  3568.           case '<':
  3569.         value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
  3570.           case '>':
  3571.         value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
  3572.           case '!':
  3573.         value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
  3574.           case '=':
  3575.         value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
  3576.           }
  3577.         value = ASSIGN; goto done;
  3578.       }
  3579.     else if (c == c1)
  3580.       switch (c)
  3581.         {
  3582.         case '+':
  3583.           value = PLUSPLUS; goto done;
  3584.         case '-':
  3585.           value = MINUSMINUS; goto done;
  3586.         case '&':
  3587.           value = ANDAND; goto done;
  3588.         case '|':
  3589.           value = OROR; goto done;
  3590.         case '<':
  3591.           c = LSHIFT;
  3592.           goto combine;
  3593.         case '>':
  3594.           c = RSHIFT;
  3595.           goto combine;
  3596.         }
  3597.     else if ((c == '-') && (c1 == '>'))
  3598.       {
  3599.         nextchar = skip_white_space (getch ());
  3600.         if (nextchar == '(')
  3601.           {
  3602.         int next_c = skip_white_space (getch ());
  3603.         if (next_c == ')')
  3604.           {
  3605.             nextchar = -1;
  3606.             value = POINTSAT_LEFT_RIGHT;
  3607.             goto done;
  3608.           }
  3609.         ungetc (next_c, finput);
  3610.           }
  3611.         value = POINTSAT;
  3612.         goto done;
  3613.       }
  3614.     else if (c1 == '?' && (c == '<' || c == '>'))
  3615.       {
  3616.         token_buffer[3] = 0;
  3617.  
  3618.         c1 = getch ();
  3619.         yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
  3620.         if (c1 == '=')
  3621.           {
  3622.         /* <?= or >?= expression.  */
  3623.         token_buffer[2] = c1;
  3624.         value = ASSIGN;
  3625.           }
  3626.         else
  3627.           {
  3628.         value = MIN_MAX;
  3629.         nextchar = c1;
  3630.           }
  3631.         if (pedantic)
  3632.           error ("use of `operator %s' is not standard C++",
  3633.              token_buffer);
  3634.         goto done;
  3635.       }
  3636.  
  3637.     nextchar = c1;
  3638.     token_buffer[1] = 0;
  3639.  
  3640.     if ((c == '<') || (c == '>'))
  3641.       value = ARITHCOMPARE;
  3642.     else value = c;
  3643.     goto done;
  3644.       }
  3645.  
  3646.     case ':':
  3647.       c = getch ();
  3648.       if (c == ':')
  3649.     {
  3650.       token_buffer[1] = ':';
  3651.       token_buffer[2] = '\0';
  3652.       value = SCOPE;
  3653.       yylval.itype = 1;
  3654.     }
  3655.       else
  3656.     {
  3657.       nextchar = c;
  3658.       value = ':';
  3659.     }
  3660.       break;
  3661.  
  3662.     case 0:
  3663.       /* Don't make yyparse think this is eof.  */
  3664.       value = 1;
  3665.       break;
  3666.  
  3667.     case '(':
  3668.       /* try, weakly, to handle casts to pointers to functions.  */
  3669.       nextchar = skip_white_space (getch ());
  3670.       if (nextchar == '*')
  3671.     {
  3672.       int next_c = skip_white_space (getch ());
  3673.       if (next_c == ')')
  3674.         {
  3675.           nextchar = -1;
  3676.           yylval.ttype = build1 (INDIRECT_REF, 0, 0);
  3677.           value = PAREN_STAR_PAREN;
  3678.         }
  3679.       else
  3680.         {
  3681.           ungetc (next_c, finput);
  3682.           value = c;
  3683.         }
  3684.     }
  3685.       /* Go down for a (X::*) or (X::&).  */
  3686.       else if (isalpha (nextchar) || nextchar == '_' || nextchar == '$')
  3687.     {
  3688.       YYSTYPE this_yylval = yylval;
  3689.       tree this_lastiddecl = lastiddecl;
  3690.       nextyychar = yylex ();
  3691.       if (nextyychar == TYPENAME_SCOPE)
  3692.         {
  3693.           if (nextchar < 0)
  3694.         nextchar = skip_white_space (getch ());
  3695.           if (nextchar == '*' || nextchar == '&')
  3696.         {
  3697.           int next_c = skip_white_space (getch ());
  3698.           if (next_c == ')')
  3699.             {
  3700.               nextyychar = -1;
  3701.               if (nextchar == '*')
  3702.             {
  3703.               value = PAREN_X_SCOPE_STAR_PAREN;
  3704.               yylval.ttype = build_parse_node (SCOPE_REF, yylval.ttype,
  3705.                                build_parse_node (INDIRECT_REF, 0));
  3706.             }
  3707.               else
  3708.             {
  3709.               value = PAREN_X_SCOPE_REF_PAREN;
  3710.               yylval.ttype = build_parse_node (SCOPE_REF, yylval.ttype,
  3711.                                build_parse_node (ADDR_EXPR, 0));
  3712.             }
  3713.               nextchar = -1;
  3714.             }
  3715.           else
  3716.             {
  3717.               ungetc (next_c, finput);
  3718.               nextyylval = yylval;
  3719.               nextlastiddecl = lastiddecl;
  3720.               yylval = this_yylval;
  3721.               lastiddecl = this_lastiddecl;
  3722.               value = c;
  3723.             }
  3724.         }
  3725.           else
  3726.         {
  3727.           nextyylval = yylval;
  3728.           nextlastiddecl = lastiddecl;
  3729.           yylval = this_yylval;
  3730.           lastiddecl = this_lastiddecl;
  3731.           value = c;
  3732.         }
  3733.         }
  3734.       else
  3735.         {
  3736.           nextyylval = yylval;
  3737.           nextlastiddecl = lastiddecl;
  3738.           yylval = this_yylval;
  3739.           lastiddecl = this_lastiddecl;
  3740.           value = c;
  3741.         }
  3742.     }
  3743.       else if (nextchar == ')')
  3744.     {
  3745.       nextchar = -1;
  3746.       yylval.ttype = NULL_TREE;
  3747.       value = LEFT_RIGHT;
  3748.     }
  3749.       else value = c;
  3750.       break;
  3751.  
  3752.     default:
  3753.       value = c;
  3754.     }
  3755.  
  3756. done:
  3757. /*  yylloc.last_line = lineno; */
  3758. #ifdef GATHER_STATISTICS
  3759.   token_count[value] += 1;
  3760. #endif
  3761.  
  3762.   return value;
  3763. }
  3764.  
  3765. typedef enum
  3766. {
  3767.   d_kind, t_kind, s_kind, r_kind, e_kind, c_kind,
  3768.   id_kind, op_id_kind, perm_list_kind, temp_list_kind,
  3769.   x_kind, lang_decl, lang_type, all_kinds
  3770. } tree_node_kind;
  3771. extern int tree_node_kinds[];
  3772. extern int tree_node_sizes[];
  3773. extern char *tree_node_kind_names[];
  3774.  
  3775. /* Place to save freed lang_decls which were allocated on the
  3776.    permanent_obstack.  @@ Not currently used.  */
  3777. tree free_lang_decl_chain;
  3778.  
  3779. tree
  3780. build_lang_decl (code, name, type)
  3781.      enum tree_code code;
  3782.      tree name;
  3783.      tree type;
  3784. {
  3785.   extern struct obstack *current_obstack, *saveable_obstack;
  3786.   extern struct obstack permanent_obstack;
  3787.   register tree t = build_decl (code, name, type);
  3788.   struct obstack *obstack = current_obstack;
  3789.   register int i = sizeof (struct lang_decl) / sizeof (int);
  3790.   register int *pi;
  3791.  
  3792.   if (! TREE_PERMANENT (t))
  3793.     obstack = saveable_obstack;
  3794.  
  3795. #ifdef LANG_DECL_PERMANENT
  3796.   if (free_lang_decl_chain && obstack == &permanent_obstack)
  3797.     {
  3798.       pi = (int *)free_lang_decl_chain;
  3799.       free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
  3800.     }
  3801.   else
  3802.     pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
  3803. #else
  3804.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
  3805. #endif
  3806.  
  3807.   while (i > 0)
  3808.     pi[--i] = 0;
  3809.  
  3810.   DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
  3811. #ifdef LANG_DECL_PERMANENT
  3812.   LANG_DECL_PERMANENT ((struct lang_decl *) pi)
  3813.     = obstack == &permanent_obstack;
  3814. #endif
  3815.   DECL_MAIN_VARIANT (t) = t;
  3816.   DECL_ORIGINAL_NAME (t) = name;
  3817.   if (current_lang_name == lang_name_cplusplus)
  3818.     {
  3819.       DECL_LANGUAGE (t) = lang_cplusplus;
  3820.  
  3821. #ifndef NO_AUTO_OVERLOAD
  3822.       if (code == FUNCTION_DECL && name != 0
  3823.       && ! (IDENTIFIER_LENGTH (name) == 4
  3824.         && IDENTIFIER_POINTER (name)[0] == 'm'
  3825.         && strcmp (IDENTIFIER_POINTER (name), "main") == 0)
  3826.       && ! (IDENTIFIER_LENGTH (name) > 10
  3827.         && IDENTIFIER_POINTER (name)[0] == '_'
  3828.         && IDENTIFIER_POINTER (name)[1] == '_'
  3829.         && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0))
  3830.     TREE_OVERLOADED (name) = 1;
  3831. #endif
  3832.     }
  3833.   else if (current_lang_name == lang_name_c)
  3834.     DECL_LANGUAGE (t) = lang_c;
  3835.   else abort ();
  3836.  
  3837. #ifdef GATHER_STATISTICS
  3838.   tree_node_kinds[(int)lang_decl] += 1;
  3839.   tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl);
  3840. #endif
  3841.  
  3842.   return t;
  3843. }
  3844.  
  3845. tree
  3846. build_lang_field_decl (code, name, type)
  3847.      enum tree_code code;
  3848.      tree name;
  3849.      tree type;
  3850. {
  3851.   extern struct obstack *current_obstack, *saveable_obstack;
  3852.   register tree t = build_decl (code, name, type);
  3853.   struct obstack *obstack = current_obstack;
  3854.   register int i = sizeof (struct lang_decl_flags) / sizeof (int);
  3855.   register int *pi;
  3856.  
  3857.   if (! TREE_PERMANENT (t))
  3858.     obstack = saveable_obstack;
  3859.  
  3860.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
  3861.   while (i > 0)
  3862.     pi[--i] = 0;
  3863.  
  3864.   DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
  3865.   return t;
  3866. }
  3867.  
  3868. tree
  3869. make_lang_type (code)
  3870.      enum tree_code code;
  3871. {
  3872.   extern struct obstack *current_obstack, *saveable_obstack;
  3873.   register tree t = make_node (code);
  3874.   struct obstack *obstack = current_obstack;
  3875.   register int i = sizeof (struct lang_type) / sizeof (int);
  3876.   register int *pi;
  3877.  
  3878.   if (! TREE_PERMANENT (t))
  3879.     obstack = saveable_obstack;
  3880.  
  3881.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
  3882.   while (i > 0)
  3883.     pi[--i] = 0;
  3884.  
  3885.   TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
  3886.   CLASSTYPE_MAIN_VARIANT (t) = t;
  3887.   CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t);
  3888.   CLASSTYPE_INTERFACE_UNKNOWN (t) = interface_unknown;
  3889.   CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
  3890.  
  3891.   /* Make sure this is laid out, for ease of use later.
  3892.      In the presence of parse errors, the normal was of assuring
  3893.      this might not ever get executed, so we lay it out *immediately*.  */
  3894.   build_pointer_type (t);
  3895.  
  3896. #ifdef GATHER_STATISTICS
  3897.   tree_node_kinds[(int)lang_type] += 1;
  3898.   tree_node_sizes[(int)lang_type] += sizeof(struct lang_type);
  3899. #endif
  3900.  
  3901.   return t;
  3902. }
  3903.  
  3904. void
  3905. copy_decl_lang_specific (decl)
  3906.      tree decl;
  3907. {
  3908.   extern struct obstack *current_obstack, *saveable_obstack;
  3909.   register int *old = (int *)DECL_LANG_SPECIFIC (decl);
  3910.   struct obstack *obstack = current_obstack;
  3911.   register int i = sizeof (struct lang_decl) / sizeof (int);
  3912.   register int *pi;
  3913.  
  3914.   if (! TREE_PERMANENT (decl))
  3915.     obstack = saveable_obstack;
  3916.  
  3917.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
  3918.   while (i-- > 0)
  3919.     pi[i] = old[i];
  3920.  
  3921.   DECL_LANG_SPECIFIC (decl) = (struct lang_decl *) pi;
  3922.  
  3923. #ifdef GATHER_STATISTICS
  3924.   tree_node_kinds[(int)lang_decl] += 1;
  3925.   tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl);
  3926. #endif
  3927. }
  3928.  
  3929. void
  3930. copy_type_lang_specific (type)
  3931.      tree type;
  3932. {
  3933.   extern struct obstack *current_obstack, *saveable_obstack;
  3934.   register int *old = (int *)TYPE_LANG_SPECIFIC (type);
  3935.   struct obstack *obstack = current_obstack;
  3936.   register int i = sizeof (struct lang_type) / sizeof (int);
  3937.   register int *pi;
  3938.  
  3939.   if (! TREE_PERMANENT (type))
  3940.     obstack = saveable_obstack;
  3941.  
  3942.   pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
  3943.   while (i-- > 0)
  3944.     pi[i] = old[i];
  3945.  
  3946.   TYPE_LANG_SPECIFIC (type) = (struct lang_type *) pi;
  3947.   CLASSTYPE_AS_LIST (type) = build_tree_list (NULL_TREE, type);
  3948.   if (CLASSTYPE_N_BASECLASSES (type) > 0)
  3949.     CLASSTYPE_BASECLASSES (type) = (tree *)obstack_copy (obstack, CLASSTYPE_BASECLASSES (type), (CLASSTYPE_N_BASECLASSES (type)+1) * sizeof (tree));
  3950.  
  3951. #ifdef GATHER_STATISTICS
  3952.   tree_node_kinds[(int)lang_type] += 1;
  3953.   tree_node_sizes[(int)lang_type] += sizeof(struct lang_type);
  3954. #endif
  3955. }
  3956.  
  3957. tree
  3958. build_with_cleanup (exp, type, rtl)
  3959.      tree exp;
  3960.      tree type;
  3961.      struct rtx_def *rtl;
  3962. {
  3963.   if (type != NULL_TREE || TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (exp)))
  3964.     {
  3965.       tree rval = make_node (WITH_CLEANUP_EXPR);
  3966.  
  3967.       if (type == NULL_TREE)
  3968.     type = TREE_TYPE (exp);
  3969.  
  3970.       TREE_OPERAND (rval, 0) = exp;
  3971.       TREE_OPERAND (rval, 1) = make_node (RTL_EXPR);
  3972.       TREE_OPERAND (rval, 2) = build_delete (TYPE_POINTER_TO (type),
  3973.                          build1 (ADDR_EXPR, TYPE_POINTER_TO (type), TREE_OPERAND (rval, 1)),
  3974.                          integer_two_node, LOOKUP_NORMAL, 0);
  3975.       if (rtl != 0)
  3976.     RTL_EXPR_RTL (TREE_OPERAND (rval, 1)) = rtl;
  3977.       if (TREE_CODE (exp) == CALL_EXPR
  3978.       && TREE_VALUE (TREE_OPERAND (exp, 1)) == NULL_TREE)
  3979.     TREE_VALUE (TREE_OPERAND (exp, 1)) = TREE_OPERAND (rval, 1);
  3980.       TREE_TYPE (rval) = type;
  3981.       return rval;
  3982.     }
  3983.   return NULL_TREE;
  3984. }
  3985.  
  3986. void
  3987. dump_time_statistics ()
  3988. {
  3989.   register tree prev = 0, decl, next;
  3990.   int this_time = my_gettime ();
  3991.   TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
  3992.     += this_time - body_time;
  3993.  
  3994.   fprintf (stderr, "\n******\n");
  3995.   print_time ("header files (total)", header_time);
  3996.   print_time ("main file (total)", this_time - body_time);
  3997.   fprintf (stderr, "ratio = %g : 1\n",
  3998.        (double)header_time / (double)(this_time - body_time));
  3999.   fprintf (stderr, "\n******\n");
  4000.  
  4001.   for (decl = filename_times; decl; decl = next)
  4002.     {
  4003.       next = IDENTIFIER_GLOBAL_VALUE (decl);
  4004.       IDENTIFIER_GLOBAL_VALUE (decl) = prev;
  4005.       prev = decl;
  4006.     }
  4007.  
  4008.   for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
  4009.     print_time (IDENTIFIER_POINTER (decl),
  4010.         TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
  4011. }
  4012.  
  4013. void
  4014. compiler_error (s, v, v2)
  4015.      char *s;
  4016.      int v, v2;            /* @@also used as pointer */
  4017. {
  4018.   char buf[1024];
  4019.   sprintf (buf, s, v, v2);
  4020.   error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
  4021. }
  4022.  
  4023. void
  4024. compiler_error_with_decl (decl, s)
  4025.      tree decl;
  4026.      char *s;
  4027. {
  4028.   char *name;
  4029.   count_error (0);
  4030.  
  4031.   report_error_function (0);
  4032.  
  4033.   if (TREE_CODE (decl) == PARM_DECL)
  4034.     fprintf (stderr, "%s:%d: ",
  4035.          DECL_SOURCE_FILE (DECL_CONTEXT (decl)),
  4036.          DECL_SOURCE_LINE (DECL_CONTEXT (decl)));
  4037.   else
  4038.     fprintf (stderr, "%s:%d: ",
  4039.          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  4040.  
  4041.   name = lang_printable_name (decl);
  4042.   if (name)
  4043.     fprintf (stderr, s, name);
  4044.   else
  4045.     fprintf (stderr, s, "((anonymous))");
  4046.   fprintf (stderr, " (compiler error)\n");
  4047. }
  4048.